
    
        
        
        
                
        
        
        
                
        
        
        
                
    
        
        
            
{"version":"https:\/\/jsonfeed.org\/version\/1","title":"mathspp.com feed","home_page_url":"https:\/\/mathspp.com\/blog\/tags\/probability","feed_url":"https:\/\/mathspp.com\/blog\/tags\/probability.json","description":"Stay up-to-date with the articles on mathematics and programming that get published to mathspp.com.","author":{"name":"Rodrigo Gir\u00e3o Serr\u00e3o"},"items":[{"title":"Problem #048 \u2013 trick or treat","date_published":"2021-10-31T00:00:00+02:00","id":"https:\/\/mathspp.com\/blog\/problems\/trick-or-treat","url":"https:\/\/mathspp.com\/blog\/problems\/trick-or-treat","content_html":"<p>Can you help these kids trick or treat their entire neighbourhood in this Halloween special?<\/p>\n\n<figure class=\"image-caption\"><img title=\"Photo by Taylor Rooney on Unsplash.\" alt=\"A pumpkin patch with Halloween-themed carved pumpkins.\" src=\"\/images\/b\/8\/b\/f\/1\/b8bf17758a25a232817c79feb3410cb14d8f9596-thumbnail.png\"><figcaption class=\"\">Photo by Taylor Rooney on Unsplash.<\/figcaption><\/figure><h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>It's Halloween night.\nJack, Frank, and their 98 friends are getting ready to trick or treat their entire neighbourhood.<\/p>\n<p>This year, the group of 100 friends decided they wanted to be very efficient...\nHence, tonight they won't be walking together as a huge group.\nInstead, they'll be having fun at the park, and each friend will visit one of the 100 houses of the neighborhood at a time.<\/p>\n<p>The 100 friends agreed on assigning one house per friend, so as to maximise the amount of candy they could get.\nJack is the first to go, but completely forgets the house he was assigned, so he decides to go trick or treating a random house instead.\nFrom there on, throughout the night, each friend would go to their assigned house, unless one of the other friends already went there.\nIf that's the case, the friend will just pick one of the remaining houses randomly.<\/p>\n<p>Frank is the last of the 100 friends to go.\nWhat is the probability that Frank will go trick-or-treating at the house he was assigned originally?<\/p>\n<div class=\"notices blue\">\n<p>Give it some thought!<\/p>\n<\/div>\n<p>If you need any clarification whatsoever, feel free to ask in the comment section below.<\/p>\n<h2 id=\"solvers\">Solvers<a href=\"#solvers\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Congratulations to the ones that solved this problem correctly and, in particular, to the ones\nwho sent me their correct solutions:<\/p>\n<ul><li>\n<a href=\"https:\/\/twitter.com\/m2u_84\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">Matthias W.<\/a>, Germany;<\/li>\n<li>Kees L., Netherlands;<\/li>\n<li>David H., Taiwan;<\/li>\n<\/ul><p>Know how to solve this?<\/p>\n<p>Join the list of solvers by <a href=\"mailto:rodrigo@mathspp.com?subject=Solution%20to%20Problem%20#048%20%E2%80%93%20trick%20or%20treat\" class=\"mailto\">emailing me<\/a> your solution!<\/p>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>This problem is very neat, in my opinion.\nThat's because there is a very neat solution that does not involve many calculations.<\/p>\n<p>If you are like me, and hate calculations, you are going to love this solution.<\/p>\n<p>When Jack goes out and has to pick one of the 100 houses,\none of three things happens:<\/p>\n<ol><li>Jack picks his own house (that happens with a probability of 1\/100);<\/li>\n<li>Jack picks Frank's house (that happens with a probability of 1\/100); and<\/li>\n<li>Jack picks another friend's house (that happens with a probability of 98\/100).<\/li>\n<\/ol><p>If 1. happens, we know that Frank gets to go to his originally assigned house.<\/p>\n<p>If 2. happens, we know that Frank will <em>not<\/em> go to his originally assigned house.<\/p>\n<p>Notice how scenarios 1. and 2. are equally likely to occur.<\/p>\n<p>If 3. happens, Frank (not) going to his originally assigned house will depend\non what happens next.\nLet's say that Jack visits (by mistake) the house that was destined for friend <span class=\"mathjax mathjax--inline\">\\(i\\)<\/span>,\nwhere <span class=\"mathjax mathjax--inline\">\\(i &lt; 100\\)<\/span>.\n(<span class=\"mathjax mathjax--inline\">\\(i = 100\\)<\/span>) is Frank, and that would mean we are in situation 2.<\/p>\n<p>After Jack visits the house that was assigned to his friend <span class=\"mathjax mathjax--inline\">\\(i\\)<\/span>,\nthe friends 2, 3, ..., all the way to <span class=\"mathjax mathjax--inline\">\\(i\\)<\/span>, go to their originally assigned houses.<\/p>\n<p>When it comes the time for friend <span class=\"mathjax mathjax--inline\">\\(i\\)<\/span> to go trick-or-treating,\nhow many houses are...<\/p>","summary":"Can you help these kids trick or treat their entire neighbourhood in this Halloween special?","date_modified":"2025-07-23T16:49:02+02:00","tags":["combinatorics","logic","mathematics","probability"],"image":"\/user\/pages\/02.blog\/03.problems\/p048-trick-or-treat\/thumbnail.png"},{"title":"Filling your Pok\u00e9dex - a probabilistic outlook","date_published":"2020-11-27T00:00:00+01:00","id":"https:\/\/mathspp.com\/blog\/filling-pokedex-with-random-trades","url":"https:\/\/mathspp.com\/blog\/filling-pokedex-with-random-trades","content_html":"<p>Join me in this blog post for Pok&eacute;fans and mathematicians alike.\nTogether we'll find out how long it would take to fill\nyour <em>complete<\/em> Pok&eacute;dex by only performing random trades.<\/p>\n\n<p><img alt=\"A picture of a trade happening inside Pok&eacute;mon Home\" src=\"\/images\/f\/0\/9\/f\/0\/f09f0e5a9f5f7760fd31e5c69136d00396a87871-thumbnail.jpg\"><\/p>\n<h2 id=\"objective\">Objective<a href=\"#objective\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>The objective of this blog post is to take a look at how one computes\nthe average time it takes for a random event to happen.\nWe will use a particular mechanic of the Pok&eacute;mon games as the motivating example,\nafter briefly introducing it in case you don't know it.<\/p>\n<p>More specifically, we will find out how long it would take,\non average, to complete the Pok&eacute;dex if we were only allowed\nto perform random trades.\nKeep reading below to see how long it would be!<\/p>\n<p>We will perform the necessary calculations and I will explain them step-by-step\nto you, so you learn how to do them for yourself.\nThis is done by the end of the post, so as not to break the main flow of the post.<\/p>\n<p>By the time we are done,<\/p>\n<ul><li>you will have an improved understanding of how to formulate\nthe theoretical solution;<\/li>\n<li>you will have performed calculations that involve infinite summations,<\/li>\n<li>and you will have learned a couple of tricks to compute these summations.<\/li>\n<\/ul><h2 id=\"pokemon-games-and-the-pokedex\">Pok&eacute;mon games and the Pok&eacute;dex<a href=\"#pokemon-games-and-the-pokedex\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>This brief section aims at introducing you to the world of Pok&eacute;mon.\nI will explain the very basics of the game, enough so that you understand\nthe <a href=\"#formulating-the-problem\">\"Formulating the problem\"<\/a> section that follows.\nYou can skip to that section if you already know what the Pok&eacute;mon games are all about.<\/p>\n<p>In the Pok&eacute;mon games there exist some creatures (called Pok&eacute;mon,\nshort for \"pocket monsters\") that you can capture and collect.<\/p>\n<p>Here's a low-quality image with three of them:<\/p>\n<p><img alt=\"A low-quality picture of three Pok&eacute;mon\" src=\"\/user\/pages\/02.blog\/filling-pokedex-with-random-trades\/_pokemons.jpg\"><\/p>\n<p>At the time of writing, there's <a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_Pok%C3%A9mon\" target=\"_blank\" rel=\"nofollow noopener noreferrer\" class=\"external-link no-image\">898<\/a> different Pok&eacute;mon.\nIn the games, your <em>Pok&eacute;dex<\/em> is like a catalogue of all the Pok&eacute;mon you've seen\nand you've owned, and one of the objectives of the games -\nat least for players that take the game seriously -\nis to fill the Pok&eacute;dex (i.e. meet all Pok&eacute;mon).<\/p>\n<p>Pok&eacute;mon can be met in the wild but you can also trade them with your friends\nor with random people on the Internet.<\/p>\n<p>In this blog post we wish to see how long it would take you to fill up your Pok&eacute;dex\nif all you could do was make <em>random<\/em> trades.\nThat is, if your only way of gaining\naccess to new Pok&eacute;mon was through trading, but in such a way that you had <strong>no<\/strong>\ncontrol whatsoever on the Pok&eacute;mon you would be receiving.<\/p>\n<h2 id=\"formulating-the-problem\">Formulating the problem<a href=\"#formulating-the-problem\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>We wish to see the average number of trades it would take before we got to see\nall 898 Pok&eacute;mon that exist at the time of writing.<\/p>\n<p>We will assume we start with one single Pok&eacute;mon and we will also assume that,\nin a random trade, all 898 Pok&eacute;mon are equally likely to make their way to you.<\/p>\n<p>(This assumption will make the calculations slightly easier\nbut doesn't necessarily hold,\nfor example it is...<\/p>","summary":"In this blog post I will talk about probabilities and estimated values, with Pok\u00e9mon and filling the Pok\u00e9dex as motivating example.","date_modified":"2025-07-23T16:49:02+02:00","tags":["mathematics","probability"],"image":"\/user\/pages\/02.blog\/filling-pokedex-with-random-trades\/thumbnail.jpg"},{"title":"Problem #021 - predicting coin tosses","date_published":"2020-10-18T00:00:00+02:00","id":"https:\/\/mathspp.com\/blog\/problems\/predicting-coin-tosses","url":"https:\/\/mathspp.com\/blog\/problems\/predicting-coin-tosses","content_html":"<p>Alice and Bob are going to be locked away separately and their faith depends on their guessing random coin tosses!<\/p>\n\n<figure class=\"image-caption\"><img title=\"Photo by Mark Normand from FreeImages\" alt=\"A coin half buried in the sand.\" src=\"\/images\/7\/0\/b\/2\/4\/70b247a13dc9432f0d70f43c1744b21c0fded199-coin-in-sand.jpg\"><figcaption class=\"\">Photo by Mark Normand from FreeImages<\/figcaption><\/figure>\n<h2 id=\"problem-statement\">Problem statement<a href=\"#problem-statement\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>Alice and Bob are going to be incarcerated separately. Everyday at 12h, prison guard Charles meets Alice and prison guard Daniel meets Bob. Each prison guard takes his own prison guard coin out of their pocket (a coin with heads and tails, but not necessarily a fair coin) and tosses it, showing the result to the prisoner in front of him. Then, each prisoner tries to guess what the outcome of their friend's coin toss was. That is, Alice sees the outcome of Charles's coin toss and tries to guess what outcome Bob saw from Daniel's coin toss, and vice-versa. If <em>any<\/em> of the prisoners gets it right, both are set free.<\/p>\n<p>What is the best strategy that Alice and Bob can agree upon, so that they are released as soon as possible? According to that strategy, what is the average number of days it will take them to be released?<\/p>\n<div class=\"notices blue\">\n<p>Give it some thought...<\/p>\n<\/div>\n<p>If you need any clarification whatsoever, feel free to ask in the comment section below.<\/p>\n<h2 id=\"solution\">Solution<a href=\"#solution\" class=\"toc-anchor after\" data-anchor-icon=\"#\" aria-label=\"Anchor\"><\/a><\/h2>\n<p>There is a perfect strategy that allows for Alice and Bob to escape prison on their first day of predicting the coin tosses. If you tried solving the problem but struggled, give it another go with this hint. Look for a perfect strategy, because it exists.<\/p>\n<p>For the perfect strategy, Alice should make a guess equal to the result of the coin toss in front of her and Bob makes a guess opposite to the result of the coin toss in front of him.<\/p>\n<p>To make it clear why this strategy works, let us analyse the four possible outcomes of the coin tosses:<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">Charles<\/th>\n<th style=\"text-align: center;\">Daniel<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">Heads<\/td>\n<td style=\"text-align: center;\">Heads<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Heads<\/td>\n<td style=\"text-align: center;\">Tails<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Tails<\/td>\n<td style=\"text-align: center;\">Heads<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Tails<\/td>\n<td style=\"text-align: center;\">Tails<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><br><\/p>\n<p>Note that the fact that the coins may not be fair doesn't change the fact that there are only four possible outcomes. The breakthrough comes when you realise that the outcomes that really matter are only two, which are the relationships between the two coin tosses:<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center;\">Charles<\/th>\n<th style=\"text-align: center;\">Daniel<\/th>\n<th style=\"text-align: center;\">Results are...<\/th>\n<th style=\"text-align: center;\">Who guesses<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center;\">Heads<\/td>\n<td style=\"text-align: center;\">Heads<\/td>\n<td style=\"text-align: center;\">The same<\/td>\n<td style=\"text-align: center;\">Alice<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Heads<\/td>\n<td style=\"text-align: center;\">Tails<\/td>\n<td style=\"text-align: center;\">Different<\/td>\n<td style=\"text-align: center;\">Bob<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Tails<\/td>\n<td style=\"text-align: center;\">Heads<\/td>\n<td style=\"text-align: center;\">Different<\/td>\n<td style=\"text-align: center;\">Bob<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">Tails<\/td>\n<td style=\"text-align: center;\">Tails<\/td>\n<td style=\"text-align: center;\">The same<\/td>\n<td style=\"text-align: center;\">Alice<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><br><\/p>\n<p>And that is it! No need for boring or complicated calculations.<\/p>\n<p><a href=\"https:\/\/mathspp.com\/subscribe\">Don't forget to subscribe to the newsletter<\/a> to get bi-weekly\nproblems sent straight to your inbox and to add your reaction below.<\/p>","summary":"This problem has two incarcerated friends try to predict coin tosses.","date_modified":"2025-07-23T16:49:02+02:00","tags":["probability","algorithms","game theory"],"image":"\/user\/pages\/02.blog\/03.problems\/p021-predicting-coin-tosses\/coin-in-sand.jpg"},{"title":"The birthday bet","date_published":"2018-06-14T00:00:00+02:00","id":"https:\/\/mathspp.com\/blog\/the-birthday-bet","url":"https:\/\/mathspp.com\/blog\/the-birthday-bet","content_html":"<p>In high school I had a colleague that had his birthday on the same day as I did.\nWhat a coincidence, right? Right..?<\/p>\n\n<p><img alt=\"A birthday cake with some candles\" src=\"\/images\/1\/a\/1\/2\/e\/1a12e8e06c93da5c25ce7594364cb5dc6fc83e71-birthday-cake.jpg\"><\/p>\n<p>This post has the purpose of presenting a result that may seem counterintuitive and that can provide a really nice excuse for a wager between you and one or more of your friends. For this post, when I talk about a <em>birthdate<\/em> I am only referring to the day and month of birth, not the year.<\/p>\n<p>What is the probability that you and your best friend have the same birth day and month? Even without an exact number one knows that you are much more likely to have <em>different<\/em> birthdates than having <em>equal<\/em> birthdates. Assuming all <span class=\"mathjax mathjax--inline\">\\(366\\)<\/span> days are equally likely, the probability that two people have the same birthdate is <span class=\"mathjax mathjax--inline\">\\(\\frac{1}{366} \\approx 0.27\\%\\)<\/span> and the probability that the birthdate is different is <span class=\"mathjax mathjax--inline\">\\(\\frac{365}{366} \\approx 99.73\\%\\)<\/span>.<\/p>\n<div class=\"notices blue\">\n<p>How many people do you need to have in a group so that: the probability of existing at least two people sharing the birthdate is higher than the probability of everyone having different birthdates?<\/p>\n<\/div>\n<p>What would your guess be? Half of 366, 183 people? 100? 50? 10?<\/p>\n<p>It only takes <span class=\"mathjax mathjax--inline\">\\(23\\)<\/span> people! If you have a group of <span class=\"mathjax mathjax--inline\">\\(23\\)<\/span> people, the probability that no one shares the birthdate is approximately <span class=\"mathjax mathjax--inline\">\\(49.37\\%\\)<\/span>! That is the same as saying that, in a group of <span class=\"mathjax mathjax--inline\">\\(23\\)<\/span> people, there is a <span class=\"mathjax mathjax--inline\">\\(\\approx 50.63\\%\\)<\/span> chance that two people share a birthdate.<\/p>\n<p>This seems very counterintuitive because <span class=\"mathjax mathjax--inline\">\\(23\\)<\/span> people can only cover <span class=\"mathjax mathjax--inline\">\\(23\\)<\/span> of the <span class=\"mathjax mathjax--inline\">\\(366\\)<\/span> possible days, which represents a ratio of <span class=\"mathjax mathjax--inline\">\\(\\frac{23}{366}\\approx 6.3\\%\\)<\/span>, a very low number which wouldn't make us think that <span class=\"mathjax mathjax--inline\">\\(23\\)<\/span> people were enough to make this happen. But why would you care?<\/p>\n<p>Whenever you find yourself in a group of <span class=\"mathjax mathjax--inline\">\\(23\\)<\/span> people or more, you can bet the other people of the group that at least two of you share the same birthdate. If you do this often enough, you will make money! Just like a casino: you will win some and lose some, but in the long run you are expected to profit from this.<\/p>\n<ul><li>In a group of <span class=\"mathjax mathjax--inline\">\\(23\\)<\/span>, your chances of winning are above <span class=\"mathjax mathjax--inline\">\\(50\\%\\)<\/span>;<\/li>\n<li>In a group of <span class=\"mathjax mathjax--inline\">\\(27\\)<\/span>, your chances of winning are above <span class=\"mathjax mathjax--inline\">\\(60\\%\\)<\/span>;<\/li>\n<li>In a group of <span class=\"mathjax mathjax--inline\">\\(30\\)<\/span>, your chances of winning are above <span class=\"mathjax mathjax--inline\">\\(70\\%\\)<\/span>;<\/li>\n<li>In a group of <span class=\"mathjax mathjax--inline\">\\(35\\)<\/span>, your chances of winning are above <span class=\"mathjax mathjax--inline\">\\(80\\%\\)<\/span>;<\/li>\n<li>In a group of <span class=\"mathjax mathjax--inline\">\\(41\\)<\/span>, your chances of winning are above <span class=\"mathjax mathjax--inline\">\\(90\\%\\)<\/span>.<\/li>\n<\/ul><p>How can you compute these probabilities? Take the <span class=\"mathjax mathjax--inline\">\\(n\\)<\/span> people of your group and line them up. We will be comparing the birthdate of a person with the birthdates of everyone to the left. What is the probability that the second person has a birthdate distinct from the first person? It is <span class=\"mathjax mathjax--inline\">\\(\\frac{365}{366}\\)<\/span>. What is the probability that the third person has a birthdate distinct from the two people to the...<\/p>","date_modified":"2024-08-14T19:34:45+02:00","tags":["mathematics","probability","slice of life"],"image":"\/user\/pages\/02.blog\/birthday-bet\/birthday-cake.jpg"}]}
