{"id":16342,"date":"2016-06-01T13:10:09","date_gmt":"2016-06-01T13:10:09","guid":{"rendered":"https:\/\/ygorganization.com\/?p=16342"},"modified":"2016-06-01T13:10:09","modified_gmt":"2016-06-01T13:10:09","slug":"maths2","status":"publish","type":"post","link":"https:\/\/ygorganization.com\/staging\/?p=16342","title":{"rendered":"Demystifying Probability, Part 2"},"content":{"rendered":"<p><span style=\"font-weight: 400\">In the previous article, I introduced Rustywolf\u2019s <\/span><a href=\"http:\/\/yugioh.party\"><span style=\"font-weight: 400\">Probability Calculator<\/span><\/a><span style=\"font-weight: 400\"> and we saw the calculator in action. In this article, we delve into the maths behind it.<\/span><\/p>\n<p><!--more--><\/p>\n<p><b>Binomial Coefficients<br \/>\n<\/b><span style=\"font-weight: 400\">First, we need to understand what a Binomial Coefficient is. Don\u2019t be put off by the fancy mathematical term, it\u2019s a very concrete and easy to understand object. <\/span><\/p>\n<p><span style=\"font-weight: 400\">A binomial coefficient is \u201cthe number of ways we can pick things out of a group.\u201d They look like this:<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-16344 aligncenter\" src=\"https:\/\/ygorganization.com\/staging\/wp-content\/uploads\/2016\/06\/CodeCogsEqn-1.png\" alt=\"CodeCogsEqn (1)\" width=\"30\" height=\"45\" \/><\/p>\n<p><span style=\"font-weight: 400\">You read it as \u201c4 choose 2\u201d. And that\u2019s exactly what it means: it\u2019s the number of ways of choosing 2 things out of a group of 4.<\/span><\/p>\n<p><span style=\"font-weight: 400\">What does this look like? Let\u2019s take 4 cards, A, B, C, D. Let\u2019s write out the number of different combinations of 2 cards there are.<\/span><\/p>\n<p><span style=\"font-weight: 400\">AB<br \/>\n<\/span><span style=\"font-weight: 400\">AC<br \/>\n<\/span><span style=\"font-weight: 400\">AD<br \/>\nBC<br \/>\n<\/span><span style=\"font-weight: 400\">BD<br \/>\n<\/span><span style=\"font-weight: 400\">CD<\/span><\/p>\n<p><span style=\"font-weight: 400\">That\u2019s all of the possible combinations. Any other combination would just be one of the above, but maybe in a different order. So \u201c4 choose 2\u201d = 6, because there are 6 ways of choosing 2 cards out of\u00a04.<\/span><\/p>\n<p><span style=\"font-weight: 400\">There is a mathematical formula for calculating the value of a binomial coefficient, but we won\u2019t need\u00a0it. If we want to calculate any, we can ask Google directly:<\/span><\/p>\n<p><a href=\"http:\/\/prnt.sc\/b713x3\" target=\"_blank\"><span style=\"font-weight: 400\">http:\/\/prnt.sc\/b713x3<\/span><\/a><\/p>\n<p>Google is great. It makes a convenient calculator as we can type any equations we need\u00a0directly into it.<\/p>\n<p><span style=\"font-weight: 400\">Similarly we can calculate the number of possible 5-card hands of a 40-card deck. We want the value of &#8220;40 choose 5&#8221;, or in maths notation,\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-16353\" src=\"https:\/\/ygorganization.com\/staging\/wp-content\/uploads\/2016\/06\/CodeCogsEqn.png\" alt=\"CodeCogsEqn\" width=\"25\" height=\"23\" \/>\u00a0:<\/span><\/p>\n<p><a href=\"http:\/\/prnt.sc\/ba8325\" target=\"_blank\">http:\/\/prnt.sc\/ba8325<\/a><\/p>\n<p><span style=\"font-weight: 400\">Of course, if we\u2019re running multiple copies of a particular card, some of these hands would look the same.<\/span><\/p>\n<p><b>The Hypergeometric Distribution<br \/>\n<\/b><span style=\"font-weight: 400\">\u2018Hypergeometric Distribution\u2019 is, as far as we&#8217;re concerned, just a fancy mathematical term for the maths describing drawing cards from a deck. <\/span><\/p>\n<p><span style=\"font-weight: 400\">It\u2019ll be easiest to see as an example. Let\u2019s suppose we want to know the probability in a 5-card hand of drawing the 1 Allure we run, but no Darks out of 5, out of a 40 card deck in total. <\/span><\/p>\n<p><span style=\"font-weight: 400\">This means:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Out of 1 Allure, we choose 1<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Out of 5 Darks, we choose 0<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Out of the rest of the deck, which is 34 cards, we choose 4 (to make up the rest of the hand)<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400\">The Hypergeometric Distribution then tells us that the chance is given by:<\/span><\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-16345 aligncenter\" src=\"https:\/\/cdn.ygorganization.com\/2016\/06\/CodeCogsEqn-5.png\" alt=\"CodeCogsEqn (5)\" width=\"77\" height=\"52\" \/><\/p>\n<p><span style=\"font-weight: 400\">(Recall\u00a0that in maths, the symbols being directly next to each other just means they are being multiplied.)<\/span><\/p>\n<p><span style=\"font-weight: 400\">Isn\u2019t this pretty? The <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16356\" src=\"https:\/\/ygorganization.com\/staging\/wp-content\/uploads\/2016\/06\/CodeCogsEqn-3.png\" alt=\"CodeCogsEqn (3)\" width=\"18\" height=\"23\" \/>\u00a0is the Allure part, the\u00a0<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16355\" src=\"https:\/\/ygorganization.com\/staging\/wp-content\/uploads\/2016\/06\/CodeCogsEqn-2.png\" alt=\"CodeCogsEqn (2)\" width=\"18\" height=\"23\" \/> is the Darks part, the <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16357\" src=\"https:\/\/ygorganization.com\/staging\/wp-content\/uploads\/2016\/06\/CodeCogsEqn-4.png\" alt=\"CodeCogsEqn (4)\" width=\"25\" height=\"23\" \/>\u00a0is the Rest of Deck part, and we divide it by\u00a0<img decoding=\"async\" class=\"alignnone size-full wp-image-16353\" src=\"https:\/\/ygorganization.com\/staging\/wp-content\/uploads\/2016\/06\/CodeCogsEqn.png\" alt=\"CodeCogsEqn\" width=\"25\" height=\"23\" \/>, which is the total number of possible 5 card hands out of a 40 card deck.<\/span><\/p>\n<p><span style=\"font-weight: 400\">It\u2019s really easy to put these into Google as well. We just type each binomial coefficient as normal, using * for multiplication and \/ for division:<\/span><\/p>\n<p><a href=\"http:\/\/prnt.sc\/b772d4\" target=\"_blank\"><span style=\"font-weight: 400\">http:\/\/prnt.sc\/b772d4<\/span><\/a><\/p>\n<p><span style=\"font-weight: 400\">The answer of 0.07047938626, when rounded up to 0.0705, matches up with the<strong><span style=\"color: #339966\"> 7.05<\/span><\/strong>% that Rusty&#8217;s calculator gives.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Interestingly, if we take the numbers above the line, we see the top row (the 1, 5, and 34) add up to\u00a0the number of cards in the Deck, and the lower row (the 1, 0, and 4) equals the size of the hand. This will always be the case, and serves as a good sanity check.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Let\u2019s see another example. Suppose we want to find the probability of opening all 5 Exodia pieces. <\/span><\/p>\n<ul>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Out of 1 Left Leg, we want 1<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Out of 1 Right Leg, we want 1<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Out of 1 Left Arm, we want 1<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Out of 1 Right Arm, we want 1<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Out of 1 Exodia head, we want 1<\/span><\/li>\n<li style=\"font-weight: 400\"><span style=\"font-weight: 400\">Out of the rest of the 35 cards, we want 0<\/span><\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16346 aligncenter\" src=\"https:\/\/cdn.ygorganization.com\/2016\/06\/CodeCogsEqn-7.png\" alt=\"CodeCogsEqn (7)\" width=\"146\" height=\"52\" \/><\/p>\n<p><span style=\"font-weight: 400\">As it happens, <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16356\" src=\"https:\/\/ygorganization.com\/staging\/wp-content\/uploads\/2016\/06\/CodeCogsEqn-3.png\" alt=\"CodeCogsEqn (3)\" width=\"18\" height=\"23\" \/> and <img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-16358\" src=\"https:\/\/ygorganization.com\/staging\/wp-content\/uploads\/2016\/06\/CodeCogsEqn-6.png\" alt=\"CodeCogsEqn (6)\" width=\"25\" height=\"23\" \/>\u00a0are both equal to 1, so the whole thing boils down to:\u00a0<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16347 aligncenter\" src=\"https:\/\/ygorganization.com\/staging\/wp-content\/uploads\/2016\/06\/CodeCogsEqn-8.png\" alt=\"CodeCogsEqn (8)\" width=\"30\" height=\"45\" \/><\/p>\n<p><span style=\"font-weight: 400\">Which Google will readily calculate at 0.00000151973, or <strong><span style=\"color: #339966\">0.00015<\/span><\/strong>%.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Incidentally, the calculator can\u2019t get this one properly &#8211; it rounds the answer down to 0.00%.<\/span><\/p>\n<p><b>Drawing at least 1 Lonefire<br \/>\n<\/b><span style=\"font-weight: 400\">Suppose we have 2 Lonefire in our deck, and we want to work out the chance of drawing at least 1. <\/span><\/p>\n<p><span style=\"font-weight: 400\">At the moment, we can only calculate the chance of drawing a specific number. But not to worry. We can break this down into cases of drawing a specific numbers of Lonefires in the obvious way: <\/span><\/p>\n<p><span style=\"font-weight: 400\">Case 1: We draw exactly 1 Lonefire, with probability:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16348 aligncenter\" src=\"https:\/\/cdn.ygorganization.com\/2016\/06\/CodeCogsEqn-9.png\" alt=\"CodeCogsEqn (9)\" width=\"53\" height=\"52\" \/><br \/>\n<span style=\"font-weight: 400\">This turns out to be 0.22435897435.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Case 2: We draw both Lonefires, with probability:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16349 aligncenter\" src=\"https:\/\/cdn.ygorganization.com\/2016\/06\/CodeCogsEqn-10.png\" alt=\"CodeCogsEqn (10)\" width=\"53\" height=\"52\" \/><br \/>\n<span style=\"font-weight: 400\">This comes out to 0.01282051282.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Now we simply add the probabilities! Our total answer is 0.23717948717, or, rounding, <span style=\"color: #339966\">23.72<\/span>%.<\/span><\/p>\n<p><span style=\"font-weight: 400\">The same idea would work if we were running all 3 Lonefire. We would just split into 3 cases instead of 2. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Alternately we could use the technique in the next example.<\/span><\/p>\n<p><b>Drawing at least 1 Ravine<br \/>\n<\/b>Suppose we want at least 1 Dragon Ravine in our opening hand, but we have 5 in total (2 copies of Ravine and 3 Terraforming). What we could do is split into cases, drawing exactly 1,2,3,4, or 5&#8230; but that&#8217;s a lot of work. We can save some effort by thinking a little more.<\/p>\n<p><span style=\"font-weight: 400\">There are really two possibilities here. Either we draw 0 Ravines or we draw at least 1 Ravine. These cases together have a 100% chance of happening. So, if we work out the chance of drawing 0 Ravines, we can subtract it from 100%, and that&#8217;ll leave us with the chance of drawing at least 1!<\/span><\/p>\n<p><span style=\"font-weight: 400\">Chance of drawing 0 Ravines:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16350 aligncenter\" src=\"https:\/\/cdn.ygorganization.com\/2016\/06\/CodeCogsEqn-11.png\" alt=\"CodeCogsEqn (11)\" width=\"53\" height=\"52\" \/><br \/>\n<span style=\"font-weight: 400\">Which equals 0.49335570388, i.e. <span style=\"color: #3366ff\">49.336<\/span>%.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Drawing at least 1: <\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16351 aligncenter\" src=\"https:\/\/cdn.ygorganization.com\/2016\/06\/CodeCogsEqn-12.png\" alt=\"CodeCogsEqn (12)\" width=\"77\" height=\"52\" \/><br \/>\n<span style=\"font-weight: 400\">100 &#8211; <span style=\"color: #3366ff\">49.336<\/span> = <span style=\"color: #339966\">50.66<\/span>% (after rounding).\u00a0<\/span><\/p>\n<p><b>Drawing at least 1 Magician and Shark<br \/>\n<\/b><span style=\"font-weight: 400\">Now let&#8217;s say we want to know the chance of drawing at least 1 Shark and either 1 or 2 Magicians (both out of 3). <\/span><\/p>\n<p><span style=\"font-weight: 400\">Again we will break it up into cases and do each separately (at least, this is the most mindless way to do it). We just need to carefully track all of the possible combinations. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Let&#8217;s use M for magician and S for shark. We want:<\/span><\/p>\n<p><span style=\"font-weight: 400\">1M+1S<br \/>\n<\/span><span style=\"font-weight: 400\">1M+2S<br \/>\n<\/span><span style=\"font-weight: 400\">1M+3S<br \/>\n<\/span><span style=\"font-weight: 400\">2M+1S<br \/>\n<\/span><span style=\"font-weight: 400\">2M+2S<br \/>\n<\/span><span style=\"font-weight: 400\">2M+3S<\/span><\/p>\n<p><span style=\"font-weight: 400\">I won\u2019t do it here, but it\u2019s entirely doable, and more importantly, it\u2019s doable without a great deal of mental effort. <\/span><\/p>\n<p><span style=\"font-weight: 400\">This is the way our calculator performs the calculations. It carefully runs through the different combinations that are wanted, and sums them together.<\/span><\/p>\n<p><b>Draw cards<br \/>\n<\/b><span style=\"font-weight: 400\">Actually there are some things our calculator cannot account for on its own, namely draw cards. Let&#8217;s see how to handle those.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Suppose we want to know the chance of drawing into at least 1 Dragon Ravine out of 5 like before, but this time we also have a (single) copy of Pot of Greed to help us.<\/span><\/p>\n<p><span style=\"font-weight: 400\">There are two cases: either we open at least 1 Ravine, or we don\u2019t open it. If we open it, we\u2019re happy and don\u2019t care what else we have in our hand. We worked this out earlier to be <span style=\"color: #3366ff\">50.66<\/span>.<\/span><\/p>\n<p><span style=\"font-weight: 400\">If we don\u2019t open it, hope is not lost if we\u2019ve drawn Pot of Greed. Let\u2019s work out the chance of this scenario occurring.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Step 1: No Ravine, but 1 Pot of Greed.<\/span><\/p>\n<p><span style=\"font-weight: 400\">This we can calculate:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16351 aligncenter\" src=\"https:\/\/cdn.ygorganization.com\/2016\/06\/CodeCogsEqn-12.png\" alt=\"CodeCogsEqn (12)\" width=\"77\" height=\"52\" \/><br \/>\n<span style=\"font-weight: 400\">This works out as 0.07047938626.<\/span><\/p>\n<p><span style=\"font-weight: 400\">Step 2: After Step 1, we then draw into Ravine from Pot of Greed. <\/span><\/p>\n<p><span style=\"font-weight: 400\">This we can also calculate exactly the same way as we have been doing. Essentially we\u2019re taking a hand size of 2 cards from a deck which now has 35 cards in it (since we\u2019ve drawn 5 already). <\/span><\/p>\n<p><span style=\"font-weight: 400\">For simplicity let\u2019s say we want exactly 1 Ravine out of the 5 we still have in the Deck:<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-16352 aligncenter\" src=\"https:\/\/cdn.ygorganization.com\/2016\/06\/CodeCogsEqn-13.png\" alt=\"CodeCogsEqn (13)\" width=\"53\" height=\"52\" \/><\/p>\n<p><span style=\"font-weight: 400\">This works out as 0.25210084033.<\/span><\/p>\n<p><span style=\"font-weight: 400\">We then <\/span><i><span style=\"font-weight: 400\">multiply <\/span><\/i><span style=\"font-weight: 400\">this answer with the probability in step 1. This is because we need both steps to happen in a row. It\u2019s like flipping a coin twice: the probability of getting 2 heads in a row is \u00bd multiplied by \u00bd. <\/span><\/p>\n<p><span style=\"font-weight: 400\">Hence our answer is: 0.0177679125, or <span style=\"color: #3366ff\">1.78<\/span>%. <\/span><\/p>\n<p>We can then add this on to the probability of opening Ravine in the first place and we get <span style=\"color: #3366ff\">50.66<\/span>+<span style=\"color: #3366ff\">1.78<\/span> = <span style=\"color: #339966\">52.44<\/span>%.<\/p>\n<p><span style=\"font-weight: 400\">I hope this article served to make the maths a little more transparent. Until next time!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous article, I introduced Rustywolf\u2019s Probability Calculator and we saw the calculator in action. In this article, we delve into the maths behind it.<\/p>\n","protected":false},"author":42,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5],"tags":[1333,1329,1330],"class_list":{"0":"post-16342","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-articles","7":"tag-its-really-not-that-bad-you-know","8":"tag-maths","9":"tag-probability"},"acf":[],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/ygorganization.com\/staging\/index.php?rest_route=\/wp\/v2\/posts\/16342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ygorganization.com\/staging\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ygorganization.com\/staging\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ygorganization.com\/staging\/index.php?rest_route=\/wp\/v2\/users\/42"}],"replies":[{"embeddable":true,"href":"https:\/\/ygorganization.com\/staging\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16342"}],"version-history":[{"count":0,"href":"https:\/\/ygorganization.com\/staging\/index.php?rest_route=\/wp\/v2\/posts\/16342\/revisions"}],"wp:attachment":[{"href":"https:\/\/ygorganization.com\/staging\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ygorganization.com\/staging\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ygorganization.com\/staging\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}