The birthday problem
How many people do you need in a room for there to be an even chance that two of them share a birthday?
Most people guess somewhere around 180 – half of 365 seems reasonable. The real answer is 23. With 70 people the chance is 99.9 %.
This is usually called the birthday paradox, but it isn't really a paradox. Nothing contradicts itself; the answer just baffles our intuition. It makes a great party trick, and if you can explain why it works, someone may even take you for a mathematician.
Why our intuition fails
When we hear the question, we tend to think about ourselves: what is the chance that someone in the room has my birthday? That chance really is small. With 22 other people it is only about 6 %.
But the question is about any two people. In a room of 23 there are
\[\binom{23}{2} = \frac{23 \cdot 22}{2} = 253\]
pairs of people, and every one of those pairs is a chance for a match. Each pair matches with a probability of only \(1/365\), but 253 small chances add up quickly.
Doing the maths
It is easier to compute the probability that no two people share a birthday, and subtract that from one. Assume 365 equally likely birthdays (ignore 29 February) and add people one at a time:
- the first person can have any birthday: \(365/365\),
- the second must avoid the first: \(364/365\),
- the third must avoid both: \(363/365\),
and so on. For \(n\) people, the probability that all birthdays differ is
\[\bar{P}(n) = \frac{365}{365} \cdot \frac{364}{365} \cdots \frac{365 - n + 1}{365} = \prod_{k=0}^{n-1} \left( 1 - \frac{k}{365} \right),\]
and the probability of at least one shared birthday is
\[P(n) = 1 - \bar{P}(n).\]
Putting in a few values:
| People \(n\) | Chance of a shared birthday |
|---|---|
| 10 | 11.7 % |
| 20 | 41.1 % |
| 23 | 50.7 % |
| 30 | 70.6 % |
| 40 | 89.1 % |
| 50 | 97.0 % |
| 57 | 99.0 % |
| 70 | 99.9 % |
A handy approximation
Since \(1 - x \approx e^{-x}\) for small \(x\), the product turns into a sum in the exponent:
\[P(n) \approx 1 - e^{-n(n-1)/(2 \cdot 365)}.\]
Setting this to one half and solving gives
\[n \approx \sqrt{2 \cdot 365 \cdot \ln 2} \approx 22.5,\]
so 23 people. More generally, with \(d\) equally likely "days", a coincidence becomes likely after only about \(1.2\sqrt{d}\) tries. That square root is why the effect shows up far beyond birthdays: in hash tables, in lottery numbers and in the so-called birthday attack on cryptographic hash functions.
And my birthday?
The intuitive question has an answer too. The chance that none of \(n\) other people shares your birthday is
\[\left( \frac{364}{365} \right)^n,\]
and for that to drop below one half you need \(n = 253\) people – exactly as many as the pairs in a room of 23.
Real birthdays
Real birthdays aren't spread evenly over the year; some weeks see noticeably more births than others. That only makes a match more likely, so 23 is, if anything, a slight overestimate.
References
- Borja, M. C. and Haigh, J. (2007). "The birthday problem". Significance, 4:124–127. doi:10.1111/j.1740-9713.2007.00246.x
- Azad, K. "Understanding the Birthday Paradox". Better Explained, retrieved 2019-08-08.
- "Probability and the birthday paradox". Scientific American, Bring Science Home.