Trials | P(all different) | P(at least one match) |
---|---|---|

1 | 1 | 0 |

2 | 0.99726 | 0.00273973 |

3 | 0.991796 | 0.00820417 |

4 | 0.983644 | 0.0163559 |

5 | 0.972864 | 0.0271356 |

6 | 0.959538 | 0.0404625 |

7 | 0.943764 | 0.0562357 |

8 | 0.925665 | 0.0743353 |

9 | 0.905376 | 0.0946238 |

10 | 0.883052 | 0.116948 |

... (355 rows omitted)

" ], "text/plain": [ "Trials | P(all different) | P(at least one match)\n", "1 | 1 | 0\n", "2 | 0.99726 | 0.00273973\n", "3 | 0.991796 | 0.00820417\n", "4 | 0.983644 | 0.0163559\n", "5 | 0.972864 | 0.0271356\n", "6 | 0.959538 | 0.0404625\n", "7 | 0.943764 | 0.0562357\n", "8 | 0.925665 | 0.0743353\n", "9 | 0.905376 | 0.0946238\n", "10 | 0.883052 | 0.116948\n", "... (355 rows omitted)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The first thing to notice in the table is the use of the label `Trials` to denote people. In probability it is common to think of random experiments as sequences of trials in which the outcome of each trial depends on chance. In the birthday problem, each person is being thought of as a trial, and we are looking to see whether there is at least one matching pair of birthdays among all the trials.\n", "\n", "Next, notice that in the boring case where there is just one person, there can't be a matching pair of birthdays, and thus $P(\\text{no match})$ has been defined as 1. In many problems there are such \"edge cases\" that have to be handled individually.\n", "\n", "Finally, notice that when the number of people is small, the chance they all have different birthdays is large. This is consistent with our intuition that if the number of individuals is small relative to the number of available hash values, and you assign values to individuals at random, then the chance of a collision is small." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The Birthday \"Paradox\" ###\n", "But the chance of a collision increases as the number of people increases. In fact, it increases rather sharply." ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAFcCAYAAAAkiW7CAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALE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EPr06SPoQA4nJyd8/vnn+P3333H+/HlMnDgRMTEx2Lx5sybCJ2oQkz5RM9VNulpaWiqvVVdXY/fu3U36HE9PT3z66aewt7fH77//rtEYiZ7EMX2iZvLy8oKbmxuWLl0KiUQCCwsLrF+//qnvKysrw+jRoxESEoLu3bvD0tISBw4cQGlpKYYMGaKDyMmcMekTNZOVlRW2bduGyMhIzJw5E+3bt8ekSZPg5uaG//qv/2rwfTY2Nujduze2bNmC27dvQywWw8PDAxs3bsSIESN02AIyRzwukYjIjHBMn4jIjDDpExGZESZ9IiIzwqRPRGRGmPSJiMwIkz4RkRlh0iciMiNM+kREZoRJn4jIjPw/PrmUIqwpgsUAAAAASUVORK5CYII=\n", "text/plain": [ ""
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"results.scatter('Trials', 'P(at least one match)')\n",
"plt.xlim(0, N/3)\n",
"plt.ylim(0, 1);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"You can see that if there are more than about 50 people, then the chance of a matching pair of birthdays is pretty close to 1. \n",
"\n",
"How many people must there be for the chance of a collision to be more than 50%? Let's see if we can find the smallest number of people for which this happens."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"

"
],
"text/plain": [
"Trials | P(all different) | P(at least one match)\n",
"23 | 0.492703 | 0.507297"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"results.where('P(at least one match)', are.between(0.5, 0.51))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"With just 23 people, a match is more likely than not. This surprises those who haven't done the calculation, and hence is known as the *birthday paradox*. But in fact there is nothing paradoxical or contradictory about it at all. It just has to do with the way the chance of a matching pair of birthdays grows as a function of the number of people."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We have done the calculation for $N = 365$, but how fast would the function have grown had $N$ been some other number? We need to know this if we are going to apply our results in contexts other than birthdays.\n",
"\n",
"To figure this out, we could redo our code for various different values of $N$ and see what the output tells us for those values. But it is altogether more efficient and insightful to use math, which is what we will do in the next section."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.3"
}
},
"nbformat": 4,
"nbformat_minor": 1
}

Trials | P(all different) | P(at least one match) |
---|---|---|

23 | 0.492703 | 0.507297 |