<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>[blog.rayfoo] &#187; geeks</title>
	<atom:link href="http://blog.rayfoo.info/tag/geeks/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.rayfoo.info</link>
	<description>Infosec, DFIR, tech geekery, thoughts and whatnot</description>
	<lastBuildDate>Wed, 25 Jan 2012 00:36:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How a visit to the pub with friends ends up in a sleepless night</title>
		<link>http://blog.rayfoo.info/2010/07/how-a-visit-to-the-pub-with-friends-ends-up-in-a-sleepless-night</link>
		<comments>http://blog.rayfoo.info/2010/07/how-a-visit-to-the-pub-with-friends-ends-up-in-a-sleepless-night#comments</comments>
		<pubDate>Fri, 23 Jul 2010 19:21:26 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[geeks]]></category>
		<category><![CDATA[mathematics]]></category>
		<category><![CDATA[probability]]></category>
		<category><![CDATA[pub]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=663</guid>
		<description><![CDATA[Dropped by a pub with some (good) friends for a short while of drinks and games, where this game was introduced for the first time to me.  It's called the "Guessing Game", where basically each participant has a cup of five dice each, and after shaking it, looks at his/her own dice combination, comes up [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_664" class="wp-caption alignright" style="width: 210px"><a href="http://www.flickr.com/photos/mkamp/2478311790/"><img class="size-full wp-image-664" title="blackdice" src="http://blog.rayfoo.info/wp-content/uploads/2010/07/blackdice.jpg" alt="" width="200" height="133" /></a><p class="wp-caption-text">Did you know that humans are naturally bad at sensing probability?</p></div>
<p>Dropped by a pub with some (good) friends for a short while of drinks and games, where this game was introduced for the first time to me.  It's called the "Guessing Game", where basically each participant has a cup of five dice each, and after shaking it, looks at his/her own dice combination, comes up with guesses on how many dice there are at least of a certain number (1-6).  Forfeits are dealt accordingly to those who were found to have guessed wrongly, or have wrongly tried to catch someone else's guess.</p>
<p>The first thing my mind came to was <em>how to win this game</em>?  And being a maths geek it certainly didn't help when the game involved dice. <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  Nonetheless I hope I still get invited to go out (drinking or otherwise) with them. :S</p>
<p>(If you do not wish to see how a good social game is ruined/analyzed to death by a geek, you should stop reading here.  And I am not responsible for your shunning if you use this eventually for your "unfair" advantage <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  )</p>
<p><span id="more-663"></span>The scenario then was set like this: 7 people, holding a cup of 5 dice each, with 6 possibilities per die (duh).</p>
<p>So...let's start from the simpler case first: If I wanted at least 7 of one number, what's the <a href="http://en.wikipedia.org/wiki/Probability">probability</a>?</p>
<p>One way I could think of is to split up the number of dice needed per person: meaning 1 die needed per person at least.  So the problem then becomes: If I wanted at least 1 of a particular number in a set of 5 dice, what's the probability?</p>
<p>Assuming all dice do not affect one another, and are perfectly fair (no such thing for either thing in the real world...), we could take the roll to be the same as rolling each of the 5 dice one by one.  Which means 1/6 + 1/6 + 1/6 + 1/6 + 1/6 = 5/6 probability (83.33%), which is darned high for risk adverse people heh.  Alternatively, based on this you would (statistically) only get one wrong out of six guesses, pretty safe for someone avoiding forfeits <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>Problem is that this works easily for guessing only one die per set.  (And I'm not too sure whether the reasoning/working for the above is correct or not!)  What if we need to know the probability for at least 2 out of 5 dice to be at a number?  Or at least 10 out of 35 dice?  How do we do such <a href="http://www.mathsisfun.com/combinatorics/combinations-permutations.html">repeated-combinations probability</a> calculations?  And more importantly, how to do it in a way that's possible to calculate <em>mentally</em>?</p>
<p>For those who're wondering about the sleepless night part of the title, it's 3.20am now.</p>
<p><a name="solution"></a>[edited 26 July to add my workings/solution] As said, this exercise is for interest only, so please don't use it in  real life with friends!  That is if you're able to mentally calculate  all these anyway... <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>[edit 4 Aug] changed greatly after LSC's corrections in the comments below</p>
<h2>Question/Solution/Formula/Analysis wrap-up</h2>
<p>Here's to wrap up the question:</p>
<blockquote><p>Assuming all dice rolls are independently fair, given <em>n</em> rolls of dice, what's the probability of guessing at least <em>r</em> dice' number correctly?</p></blockquote>
<p>The solution as follows:</p>
<p>The <a href="http://www.mathgoodies.com/lessons/vol6/intro_probability.html">probability</a> of an event A occuring is defined as "the number of ways event A can occur" divided by "the total number of possible outcomes".</p>
<p>This means that for <em>n</em> dice rolls, the total number of possible outcomes is always 6^n.</p>
<p>To work out the formula,we define <em>P(a, n)</em> to be the probability of exactly <em>a</em> out of <em>n</em> dice rolls to have the same outcome (i.e. your guess).  Therefore <em>P(0, n) + P(1, n) + P(2, n) + ... + P(n, n) = 1</em> as dictated by the rules of probability.</p>
<p>As an example, starting off with n=3:  The possible ways where a=1 can occur are as follows (note that { g } denotes the die position where the guess was correct, and {1-5} denotes the possible outcomes for dice in those positions):</p>
<p>For n=3, a=1:<br />
<code>{ g } {1-5} {1-5}<br />
{1-5} { g } {1-5}<br />
{1-5} {1-5} { g }</code></p>
<p>For n=3, a=2:<br />
<code>{ g } { g } {1-5}<br />
{ g } {1-5} { g }<br />
{1-5} { g } { g }</code></p>
<p>The pattern we see here is that  there will always be nCa ways of representing the positions where the guess was right.  Also, since we're interested in the number of ways where the die rolls can turn out, for every row above  it represents 5^(n-a) possible outcomes.</p>
<p>So, for n=3, a=1: the number of ways for exactly <em>a</em> dice to be guessed right is 3C1 * 5^(3-1)</p>
<p>And for n=1, a=2: the number of ways for exactly <em>a</em> dice to be guessed right is 3C2 * 5^(3-2)</p>
<p>Thus the formula:</p>
<blockquote><p>Number of ways for exactly <em>a </em>dice to be guessed right out of <em>n</em> die rolls is <span style="color: #339966;">nCa * 5^(n-a)</span></p></blockquote>
<p>And since we're interested in the probability:</p>
<blockquote><p><span style="color: #339966;">P(a, n) = nCa * 5^(n-a) / 6^n</span><span style="color: #339966;"><br />
</span></p></blockquote>
<p>For the original problem statement, we want to find out the probabilities where we can "guess" at least <em>r</em> out of <em>n</em> dice rolls correctly.  So in order to do so, we only need to sum them accordingly (basically is the reverse of a CDF that we usually do):</p>
<blockquote><p>P(at least <em>r</em> out of <em>n</em> dice guessed correctly)<br />
= P(r, n) + P(r+1, n) + P(r+2, n) + ... + P(n, n)</p></blockquote>
<p>Which is absolutely horrid for mental calculations! D:</p>
<p>Let's analyze this a bit: putting this formula into n=5 for each person's set only:</p>
<div id="attachment_707" class="wp-caption aligncenter" style="width: 610px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/07/diceprob-n5.png"><img class="size-full wp-image-707 " title="diceprob-n5" src="http://blog.rayfoo.info/wp-content/uploads/2010/07/diceprob-n5.png" alt="" width="600" height="340" /></a><p class="wp-caption-text">Graph for P(a, n) using n=5, and &quot;reverse&quot; CDF</p></div>
<p>Looking at the orange line, this shows that to get at least 1 out of 5 would be still pretty safe (0.6 probability), but to get at least 2 out of 5 would be pretty dangerous already (0.2 probability),  and the chances go down south with 3 and onwards...</p>
<p>Now for n=35, simulating everybody's dice rolls...</p>
<div id="attachment_708" class="wp-caption aligncenter" style="width: 610px"><a href="http://blog.rayfoo.info/wp-content/uploads/2010/07/diceprob-n35.png"><img class="size-full wp-image-708 " title="diceprob-n35" src="http://blog.rayfoo.info/wp-content/uploads/2010/07/diceprob-n35.png" alt="" width="600" height="340" /></a><p class="wp-caption-text">Graph for P(a, n) using n=35, and &quot;reverse&quot; CDF</p></div>
<p>The chances of getting at least 6 out of 35  guessed right is about 0.53, and degrades pretty quickly with at least 7 to be about 0.37, and 8 at slightly above 0.2 (1 in 5!).</p>
<p>So the only "real" guesses for that game would be 5-6 (pretty ok), 7 (if you want some extra drinks by losing), and 8 (if you're feeling really adventurous due to the alcohol). <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/07/how-a-visit-to-the-pub-with-friends-ends-up-in-a-sleepless-night/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>OFFER AT NO MINIMUM COST!</title>
		<link>http://blog.rayfoo.info/2010/01/offer-at-no-minimum-cost</link>
		<comments>http://blog.rayfoo.info/2010/01/offer-at-no-minimum-cost#comments</comments>
		<pubDate>Sat, 30 Jan 2010 16:07:55 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Downloads]]></category>
		<category><![CDATA[geeks]]></category>
		<category><![CDATA[guinea pigs]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=409</guid>
		<description><![CDATA[Ok, I probably didn't put the point across properly previously, so let's try again: For those who do use public WiFi, here's a good chance to protect your web traffic from sniffers at ZERO MINIMUM COST! For more details contact me at secureme{@T}rayfoo[dot]info or you could read another really lengthy post here.]]></description>
			<content:encoded><![CDATA[<p>Ok, I probably didn't put the point across properly <a href="http://blog.rayfoo.info/2010/01/secureme-starting-off">previously</a>, so let's try again:</p>
<p>For those who do use public WiFi, here's a good chance to protect your web traffic from sniffers at ZERO MINIMUM COST! <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>For more details contact me at secureme{@T}rayfoo[dot]info or you could read another really lengthy post <a href="http://blog.rayfoo.info/2009/11/project-secureme">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/01/offer-at-no-minimum-cost/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SecureMe: starting off</title>
		<link>http://blog.rayfoo.info/2010/01/secureme-starting-off</link>
		<comments>http://blog.rayfoo.info/2010/01/secureme-starting-off#comments</comments>
		<pubDate>Thu, 28 Jan 2010 12:36:15 +0000</pubDate>
		<dc:creator>ray</dc:creator>
				<category><![CDATA[Everything]]></category>
		<category><![CDATA[Downloads]]></category>
		<category><![CDATA[geeks]]></category>
		<category><![CDATA[guinea pigs]]></category>
		<category><![CDATA[helpers]]></category>
		<category><![CDATA[project]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.rayfoo.info/?p=401</guid>
		<description><![CDATA[Am starting off with SecureMe for the more technically inclined. (Heh, it's pretty fun to be typing this from outside whilst using SecureMe.  But that's not the point.) If you're ok/familiar with installing + basic configuration of software (namely an OpenVPN client) and know how to configure your browser to use proxies, you're the guys/gals [...]]]></description>
			<content:encoded><![CDATA[<p>Am starting off with SecureMe for the more technically inclined.</p>
<p>(Heh, it's pretty fun to be typing this from outside whilst using SecureMe.  But that's not the point.)</p>
<p>If you're ok/familiar with installing + basic configuration of software (namely an OpenVPN client) and know how to configure your browser to use proxies, you're the guys/gals I'm looking for!</p>
<p>Let me know if you wish to have a VPN + proxy + DNS resolver service for no minimum cost (read: donorware should you feel like it).  Am limiting this offer to the first two people for now.  (The same offer still stands for those who've responded to my earlier call for helpers, so don't worry.)</p>
<p>The only things I need of you:</p>
<p>1) you need to be savvy enough to at least know how to install stuff on your computer, and to configure your browser</p>
<p>2) also, it would be good if you can help me in my efforts to make his easier for the less technically inclined.  Not a requirement though <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> </p>
<p>So...let me know if you want to try this out for free!  I promise to keep it free/donorware for these two respondents as long as I can run this service <img src='http://blog.rayfoo.info/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>You can contact me via Twitter or Facebook (you should be able to find the links at <em>least</em>), or if you're paranoid enough not to use these services you could alternatively email me at secureme{@T}rayfoo[dot]info and I'll get back to ya asap.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.rayfoo.info/2010/01/secureme-starting-off/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

