{"id":670,"date":"2010-03-25T21:53:52","date_gmt":"2010-03-26T03:53:52","guid":{"rendered":"http:\/\/thesmithfam.org\/blog\/?p=670"},"modified":"2019-08-12T07:15:31","modified_gmt":"2019-08-12T13:15:31","slug":"never-tell-me-the-odds","status":"publish","type":"post","link":"https:\/\/thesmithfam.org\/blog\/2010\/03\/25\/never-tell-me-the-odds\/","title":{"rendered":"Never tell me the odds!"},"content":{"rendered":"<p><img decoding=\"async\" src=\"\/images\/m-and-m-big-bag.jpg\" align=\"center\"\/><\/p>\n<p>M&#038;Ms are yummy. At work we have ginormous bags of M&#038;Ms to snack on. One day I reached into the bag and pulled out a handful (about 8 M&#038;Ms). I happily munched until there were 4 left. Lo and behold! The remaining 4 were all blue. &#8220;What are the odds,&#8221; I asked myself. So I set out to find the answer.<\/p>\n<p>I started by figuring out how many different M&#038;M colors there were. My bag had 6:<\/p>\n<ul>\n<li>red<\/li>\n<li>green<\/li>\n<li>blue<\/li>\n<li>brown<\/li>\n<li>yellow<\/li>\n<li>orange<\/li>\n<\/ul>\n<p>Then I assumed that there were an equal number of each color in the bag (that may not actually be true, but it makes the problem a tad easier to solve).<\/p>\n<p>Armed with this information, I started up the wayback machine to go back to Computer Science 235, when, back in my college days, I studied probability. This is when I realized that I had forgotten pretty much everything I knew about probability, except dice rolling odds (which I use in Risk to conquer the world). So it turned out that memory lane wasn&#8217;t that helpful after all.<\/p>\n<p>At this point I decided that I should compute the odds of choosing a handful of 8 M&#038;Ms at random with at least 4 blue ones, this being a prerequisite of having 4 blue ones left in my hand after eating the other 4. To do this, I first drew 8 boxes on my white board, to represent the 8 M&#038;Ms I could draw at random. This helped me reason about the problem. For any given box, I have a 1 in 6 chance of drawing a blue M&#038;M. If I draw a blue one for a given box, that leaves 3 more I would need to also randomly draw. So I started enumerating a few permutations that could make this happen:<\/p>\n<style>\ntable tr td.blue { color: white; background: blue; }\ntable tr td { padding: 4px; border: 1px solid black; width: 15px; height: 15px; }\ntable tr th { text-align: center; }\n<\/style>\n<table>\n<tr>\n<th>1<\/th>\n<th>2<\/th>\n<th>3<\/th>\n<th>4<\/th>\n<th>5<\/th>\n<th>6<\/th>\n<th>7<\/th>\n<th>8<\/th>\n<\/tr>\n<tr>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<\/tr>\n<tr>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<\/tr>\n<tr>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<\/tr>\n<tr>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<\/tr>\n<tr>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<\/tr>\n<tr>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td><\/td>\n<td class=\"blue\"><\/td>\n<td class=\"blue\"><\/td>\n<\/tr>\n<\/table>\n<p>And so on. I realized pretty quick that there were too many permutations to enumerate so it was time to get analytical. I started to reason this way:<\/p>\n<p>In position 1, I have a 1 in 6 chance of choosing blue, but I don&#8217;t really care which position the blue M&#038;M lands in. I also know that, if I get lucky and chose blue in position 1, that does not impact my odds of choosing blue in position 2. So each position is independent. What that means is I have a 1 in 6 chance of choosing blue the first time, and again the second time, and the third time, and the fourth time. But, and this is the kicker, I don&#8217;t have to choose blue for <b>the first 4<\/b>. It just has to be <b>any 4<\/b>.<\/p>\n<p>So if I were to compute the odds of choosing <b>all 8<\/b> blue, it would look something like this:<\/p>\n<p>1\/6 x 1\/6 x 1\/6 x 1\/6 x 1\/6 x 1\/6 x 1\/6 x 1\/6.<\/p>\n<p>That&#8217;s a good starting point. Since we don&#8217;t have to choose all 8, but only 4, blue M&#038;Ms, we can just throw out 4 of the terms, so we end up with this:<\/p>\n<p>1\/6 x 1\/6 x 1\/6 x 1\/6<\/p>\n<p>This is when I started getting confused. I started to wonder if maybe the 8 don&#8217;t have anything to do with the problem at all. Maybe the odds of choosing  8 at random, eating 4, and being left with only blue <b>are the same odds<\/b> as just randomly choosing 4 blue M&#038;Ms.<\/p>\n<p>This is when I ditched the analytical in favor of the empirical. As much as I wanted to eat 10,000 M&#038;Ms to prove my hypothesis, I decided to write a small computer program to randomly choose 8 M&#038;Ms from a virtual bag, randomly eat 4 of the virtual M&#038;Ms, and then see if the remaining M&#038;Ms were all blue. This I did, and ran it 5,000,000 times. The result: 0.077% of the time, I had 4 blue M&#038;Ms left. That&#8217;s right, 0.077% is the same as 1\/6 x 1\/6 x 1\/6 x 1\/6. So I conclude that the odds are the same, and the problems are, in fact, equivalent.<\/p>\n<p>So I beat the odds that day when I had 4 blue M&#038;Ms left. Without even trying, I did something whose odds were 1,296 to 1, against. I should have gone to Vegas that afternoon.<\/p>\n<p>P.S. The odds of having 4 M&#038;Ms left that are all the same color (any color) are 6 times easier: 1 in 216.<\/p>\n<p>P.P.S. If you want to see the source code (warning: it&#8217;s C++), just ask.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>M&#038;Ms are yummy. At work we have ginormous bags of M&#038;Ms to snack on. One day I reached into the bag and pulled out a handful (about 8 M&#038;Ms). I happily munched until there were 4 left. Lo and behold! The remaining 4 were all blue. &#8220;What are the odds,&#8221; I asked myself. So I [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,1],"tags":[],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-code-and-cruft","category-miscellany"],"_links":{"self":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/comments?post=670"}],"version-history":[{"count":30,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/670\/revisions"}],"predecessor-version":[{"id":700,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/posts\/670\/revisions\/700"}],"wp:attachment":[{"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/media?parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/categories?post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/thesmithfam.org\/blog\/wp-json\/wp\/v2\/tags?post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}