{"id":979,"date":"2005-06-07T21:37:15","date_gmt":"2005-06-07T19:37:15","guid":{"rendered":"http:\/\/unknowngenius.com\/blog\/?p=979"},"modified":"2005-07-12T19:54:59","modified_gmt":"2005-07-12T10:54:59","slug":"mathematical-riddle-the-solution","status":"publish","type":"post","link":"https:\/\/unknowngenius.com\/blog\/archives\/2005\/06\/07\/mathematical-riddle-the-solution\/","title":{"rendered":"Mathematical Riddle: The Solution"},"content":{"rendered":"<p><strong><em>[Blogger Advisory: unspeakable nerdery, use of foul language.]<\/em><\/strong><\/p>\n<p>As promised: the answer to <a href=\"https:\/\/unknowngenius.com\/blog\/archives\/2005\/06\/06\/mathematical-riddle\/\">yesterday&#8217;s riddle<\/a> (I know, suspense is killing you)&#8230;<\/p>\n<p>Upon closer inspection, maybe I went a bit ahead of myself when I postulated the solution was &#8220;really easy&#8221;. Note that the explanation below, while somewhat tedious and longwinded, should be perfectly intelligible to anybody with very basic notions of arithmetic and a few sober neurons. If you don&#8217;t fit either criteria, feel free to skip to the last paragraph.<\/p>\n<h3>The Question<\/h3>\n<blockquote><p>Does one stand better chances of: 1) getting at least <strong>one<\/strong> ace with <strong>6<\/strong> throws of a die, or 2) getting at least <strong>two<\/strong> aces with <strong>12<\/strong> throws?<\/p><\/blockquote>\n<p><!--more--><\/p>\n<h3>The Reasoning<\/h3>\n<p>First, and without getting into a complete course on stats: whatever probability you find, it better be between 0 and 1. Anything above 1, means in essence that your result would happen more times than the total number of experience (e.g. getting seven ace with six dice), which, most sources agree, would about bring our entire universe down, collapsing under the weight of its own impossibility. <\/p>\n<p>A probability of 1 means that your event will <em>always<\/em> turn true. In this regard, all those who found <code>p = 1<\/code> to either of the previous case (either throwing 6 or 12 dice) have been wasting their life so far: they should be busy getting rich at the nearest casino, where their own laws of probabilities <strong>guarantee<\/strong> them one successful draw for every six rolls (pretty good odds, if you ask me) \ud83d\ude42<\/p>\n<p>Yet, I have to agree that, at first, it may look like a sensible solution (and this is why stats problems are usually so fun): since your probability of getting a given score (say an ace) for one roll of a die is <code>p(x) = 1\/6<\/code> (with <code>x<\/code> = 1&#8230;6), it&#8217;s not <em>completely<\/em> farfetched to assume that your total probability to get an ace out of 6 draws would be <code>6 * p(1) = 1<\/code>. Except that, following the same logic, 7 draws gives you a probability of <code>7 * p(1) = 7\/6<\/code>, and before you reach the end of this thought, the whole universe has instantaneously disappeared, to be immediately replaced by a more bizarre and inexplicable one, according to <a href=\"http:\/\/www.quotationspage.com\/quote\/8.html\">Douglas Adams&#8217; 1st Law of Astrophysics<\/a>.<\/p>\n<p>Unfortunately, the solution is a <em>tad<\/em> more complicated than that:<\/p>\n<p>Let&#8217;s keep things simple and start with <strong>two<\/strong> dice. Now, we know the odds of getting any given score for one die are <code>p(x) = 1\/6<\/code>, that is: any of the six faces has an equal probability of coming up. With two dice, the total number of combinations is, quite obviously, <code>6 * 6 = 36<\/code>. That is, there are exactly 36 different possible results (1 &#038; 1, 1 &#038; 2, 1 &#038; 3 etc.), each with exactly the same odds of happening. Of these, there are <strong>11<\/strong> ways we could get at least one ace (1 &#038; 2, 1 &#038; 3 [&#8230;] 1 &#038; 6, 2 &#038; 1, 3 &#038; 1 [&#8230;] 6 &#038; 1 and 1 &#038; 1).<br \/>\nOur probability, then, is the ratio of these two numbers: <code>p(<i>at least one ace<\/i>) = [<i>ways to get at least an ace<\/i>] \/ [<i>total number of combinations<\/i>] = 11 \/ 36 = 0.30<\/code>. Roughly one out of three: not bad.<\/p>\n<p>Now, consider more dice: you would find that 3 dice have <strong>91<\/strong> ways of showing one ace or more, out of <code>6 * 6 * 6 = 216<\/code> total combinations (<code>p = 0.42<\/code>), 4 dice have <strong>671<\/strong> out of <strong>1296<\/strong> combinations (<code>p = 0.52<\/code>). And so on and so forth. Quite logically, the more dice, the better your chances of getting at least one ace.<\/p>\n<p>All in all, figuring the odds for &#8220;1 ace or more&#8221; with <code>n<\/code> dice (basically, situation 1. in the problem above) is rather straightforward for low numbers of dice. It gets tedious for more than 3 or 4 and downright daunting for 12 dice.<\/p>\n<p>Situation 2. requires a slightly more evolved logic. Let&#8217;s reduce the case and assume we want at least two aces out of <strong>3<\/strong> dice. That&#8217;s gonna be either A and B, B and C, A and C or all three A, B, C, giving an ace.<\/p>\n<p>Let&#8217;s look at the general case systematically and draw the rule (hang on to your hair, that&#8217;s where it becomes a teeny bit technical). <\/p>\n<p>Say we got <code>n<\/code> dice and want to know the odds of getting <strong>exactly<\/strong> <code>r<\/code> aces:<\/p>\n<ul>\n<li>Out of our <code>n<\/code> dice, we know there will be exactly <code>r<\/code> aces and <code>n-r<\/code> non-aces. Odds for that are: <code>p(<i>the die gives an ace<\/i>) to the power of r * p(<i>the die does <strong>not<\/strong> give an ace<\/i>) to the power of (n-r) = (1\/6)<small><sup>r<\/sup><\/small> * (5\/6)<small><sup>(n-r)<\/sup><\/small><\/code>.<\/li>\n<li>Now, the odds above are true if we have already decided <strong>which<\/strong> <code>r<\/code> dice, out of the total <code>n<\/code>, are the &#8220;winning&#8221; ones. To get the total probability, we must be multiply by the total number of ways to pick <code>r<\/code> dice out of <code>n<\/code>.<\/li>\n<li>Picking <code>r<\/code> elements out of of <code>n<\/code> total is a fairly common operation in stats, the total number of ways to do that is called a &#8220;combinatorial&#8221;, and it is equal to: <code><big>(<\/big><sup>n<\/sup><sub>r<\/sub><big>}<\/big> = [n * (n-1) * (n-2) * ... * (n-r)] \/ [r * (r-1) * (r-2) * ... * 3 * 2 * 1] = n! \/<sup class=\"modern-footnotes-footnote \" data-mfn=\"1\" data-mfn-post-scope=\"00000000000002d50000000000000000_979\"><a href=\"javascript:void(0)\"  role=\"button\" aria-pressed=\"false\" aria-describedby=\"mfn-content-00000000000002d50000000000000000_979-1\">1<\/a><\/sup><span id=\"mfn-content-00000000000002d50000000000000000_979-1\" role=\"tooltip\" class=\"modern-footnotes-footnote__note\" tabindex=\"0\" data-mfn=\"1\"><\/span>n-r)! r!)<\/code>. Stop hyperventilating: I swear it&#8217;s pretty intuitive to figure out as a result, just try with small values (e.g. picking 2 out of 3, or 2 out of 5 etc). But giving the proper explanation to the formula would really tip the scale of this entry from mild technical nerdism into full-blown pedantry (huh? &#8220;too late&#8221;? bah&#8230;).<\/li>\n<li>As such, the final formula to get the odds of getting exactly <code>r<\/code> aces and <code>n-r<\/code> non-aces is: <code>p(r) = <big>(<\/big><sup>n<\/sup><sub>r<\/sub><big>)<\/big> (1\/6)<small><sup>r<\/sup><\/small> * (5\/6)<small><sup>(n-r)<\/sup><\/small><\/code><\/li>\n<\/ul>\n<p>Last step is to add the odds for each given <code>r<\/code> (the number of ace we want), so as to cover &#8220;r aces or more&#8221;. This would be written: <code>p(r) + p(r+1) + p(r+2) + ... + p(n-1) + p(n)<\/code> (where <code>p(r)<\/code> is the probability of getting exactly <code>r<\/code> aces, as shown above).<\/p>\n<p>Depending on the value of <code>r<\/code> and <code>n<\/code>, we may want to make our life easier, and point out that the probability of getting <code>r<\/code> or more aces is: 1 &#8211; the probability of getting <strong>less than<\/strong> r aces. Alright, this one bit may not sound completely obvious (though it&#8217;s rather intuitive), but it&#8217;s only a trick to make calculations quicker in cases where <code>r = 1<\/code> and <code>n = 6<\/code>: instead of adding <code>p(1) + p(2) + p(3) + p(4) + p(5) + p(6)<\/code>, you only have to find <code>p(0)<\/code> and say that the former is <code>1 - p(0)<\/code> (since we know that <code>p(0) + p(1) + p(2) + p(3) + p(4) + p(5) + p(6) = 1<\/code>, the mathematical translation of &#8220;probability of getting zero or more aces = always&#8221;). Once again, this is only a shortcut, forget about it, if it sounds too arcane for you.<\/p>\n<p>All right, now we got the magic formula to compute the odds of getting <code>r<\/code> aces or more out of <code>n<\/code> dice. We can test it with the first results we found above:<br \/>\n<code>for n = 3,<br \/>\np(<i>getting one ace or more<\/i>) = p(1) + p(2) + p(3) + p(4) + p(5) + p(6)<br \/>\n= 1 - p(0)<br \/>\n= 1 - <big>(<\/big><sup>3<\/sup><sub>0<\/sub><big>)<\/big> * (1\/6)<small><sup>0<\/sup><\/small> * (5\/6)<small><sup>3<\/sup><\/small><br \/>\n= 1 - (1 * 1 * 125\/216)<br \/>\n= 0.42 <em>(matches what we had)<\/em><\/p>\n<p>for n = 4,<br \/>\np(<i>getting one ace or more<\/i>) = 1 - 625\/1296 = 0.52 <em>(bingo again)<\/em><\/code><\/p>\n<p>And, for 6 dice, we get&#8230; (drum rolling)&#8230;<br \/>\n<code>p(<i>getting one ace or more<\/i>) = 1 - p(0)<br \/>\n= 1 - <big>(<\/big><sup>6<\/sup><sub>0<\/sub><big>)<\/big> * (1\/6)<small><sup>0<\/sup><\/small> * (5\/6)<small><sup>6<\/sup><\/small><br \/>\n= 1 -  (5\/6)<small><sup>6<\/sup><\/small><br \/>\n= <strong>0.665<\/strong><br \/>\n<\/code><\/p>\n<p>That was for situation 1.<\/p>\n<p>Situation 2. gives a slightly more complicated result:<\/p>\n<p><code>With r = 2 and n = 12, using the magic formula:<br \/>\np(<i>getting two aces or more<\/i>) = 1 - p(0) - p(1)<br \/>\n= 1 - <big>(<\/big><sup>12<\/sup><sub>0<\/sub><big>}<\/big> * (1\/6)<small><sup>0<\/sup><\/small> * (5\/6)<small><sup>12<\/sup><\/small> - <big>(<\/big><sup>12<\/sup><sub>1<\/sub><big>}<\/big> * (1\/6)<small><sup>1<\/sup><\/small> * (5\/6)<small><sup>12<\/sup><\/small><br \/>\n= 1 -  (5\/6)<small><sup>12<\/sup><\/small> - 12 * (1\/6) * (5\/6)<small><sup>11<\/sup><\/small><br \/>\n= <strong>0.619<\/strong><br \/>\n<\/code><\/p>\n<h3>The Answer<\/h3>\n<p>Thus, you have a <strong>66.5%<\/strong> chance of getting one ace or more, out of 6 dice, and <strong>61.9%<\/strong> of getting 2 or more, out of 12. That&#8217;s somewhat <strong>weaker<\/strong> odds for situation 2.<\/p>\n<p>Just for fun: your chances to get 3+ aces out of 18 rolls of a die are even lower: 59.73%. <\/p>\n<p>The odds (of getting k+ aces out of 6k dice) keep decreasing when the number of dice increases, and slowly move toward a neat 50% for an &#8220;infinite&#8221; number of dice (i.e., for a big enough number, you&#8217;ll get very close to 50%).<\/p>\n<p>The formula above can be used for any values of <code>r<\/code> (minimum number of aces to obtain) and <code>n<\/code> (total number of dice)&#8230; see below for another common result&#8230;<\/p>\n<h3>Some Background<\/h3>\n<p>This riddle is <a href=\"http:\/\/mathworld.wolfram.com\/Newton-PepysProblem.html\">a famous one<\/a>, and was initially asked by one of the first alpha blogger there ever was: <a href=\"http:\/\/www.pepysdiary.com\/about\/\">Samuel Peppy<\/a>, a renowned 17th Century English diarist. <\/p>\n<p>There is <a href=\"http:\/\/www.pepysdiary.com\/\">a very nifty online version<\/a> of his diary, organized as a modern-day blog. It&#8217;s very much worth a check. Don&#8217;t worry: this present tidbit is probably the only such math-related in the whole of his detailed recollections of life in the times of Cromwell. At the time, Pepys submitted this problem to Isaac Newton, who graciously gave him the best option to win the bet.<\/p>\n<p>Meanwhile, in France, the Chevalier de M\u00e9r\u00e9 wondered about the probability of getting at least one &#8220;6&#8221; in four rolls of a die (0.52) vs. at least one double-six in 24 throws of two dice (0.49: slightly weaker). Pascal gave him the answer. A result that can also be figured from adapting the formula above.<\/p>\n<p>From now on, you shouldn&#8217;t lose a single dollar on a game of craps ever again in your life (provided you bring your autistic brother or a very discreet calculator).<\/p>\n<p>Next year, we demystify blackjack.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Blogger Advisory: unspeakable nerdery, use of foul language.] As promised: the answer to yesterday&#8217;s riddle (I know, suspense is killing you)&#8230; Upon closer inspection, maybe I went a bit ahead of myself when I postulated the solution was &#8220;really easy&#8221;. Note that the explanation below, while somewhat tedious and longwinded, should be perfectly intelligible to [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[1,12],"tags":[],"class_list":["post-979","post","type-post","status-publish","format-standard","hentry","category-geek","category-too-much-caffeine"],"_links":{"self":[{"href":"https:\/\/unknowngenius.com\/blog\/wp-json\/wp\/v2\/posts\/979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknowngenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknowngenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknowngenius.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/unknowngenius.com\/blog\/wp-json\/wp\/v2\/comments?post=979"}],"version-history":[{"count":0,"href":"https:\/\/unknowngenius.com\/blog\/wp-json\/wp\/v2\/posts\/979\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknowngenius.com\/blog\/wp-json\/wp\/v2\/media?parent=979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknowngenius.com\/blog\/wp-json\/wp\/v2\/categories?post=979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknowngenius.com\/blog\/wp-json\/wp\/v2\/tags?post=979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}