The Birthday Paradox

Probability can be a bit counter-intuitive at times. Take for example, the birthday problem / paradox: how many people do you need in a room to have a 50⁄50 chance that two share the same birthday?

Turns out, it’s not as many as you might think: you only need 23.

Why? Math!

If you have one person, it’s guaranteed that you won’t have duplicated birthdays. If you have two, there is a 1⁄365 chance (we’re going to ignore Leap Days for the time being). You can think of it by randomly choosing the first birthday then finding the chance of matching that.

The math starts getting a bit more interesting when you have three people. Rather than directly calculating the problem, consider the inverse. Start with the chance that the second person doesn’t match the first and then add the chance that the third doesn’t match either the first or second:

(1 - 1/365) * (1 - 2/365) \approx 99.2\%

One minus that is the chance that any of the three share a birthday:

1 - ((1 - 1/365) * (1 - 2/365)) \approx 0.8\%

Then if you have four:

1 - ((1 - 1/365) * (1 - 2/365) * (1 - 3/365)) \approx 1.6\%

Which generalizes pretty directly to any number of people n:

B(n) = 1 - \prod_{i=1}^{(n-1)}(1-\frac{i}{365})

Working out several interesting values of n:

n

B(n)

1

0.8%

2

1.6%

3

2.7%

5

5.6%

10

11.7%

20

41.1%

23

50.7%

30

70.6%

50

97.0%

57

99.0%

100

99.9%

366

100%

So it turns out, you only need 23 people to get a 50⁄50 chance of two sharing the same birthday. That’s about what you’d seen in the average classroom.
Not what you’d probably expect, but the math holds it out. There’s also another interesting factor going on that once you have 367 people in a room (one more than the possible number of days in a year, then are guaranteed to have a match). That’s from the pigeonhole principle, but hopefully it’s more intuitive as well. If you have 366 people spread out all over the year, even on February 29, then when could the 367’s birthday possibly be to not overlap? Exactly.

But you don’t have to take my word for it, the math should stand by itself. And if that’s not enough, here’s a quick script that might just help to convince you. Just click the button to generate a random room of 23 people. Run it enough times and you should see that 50⁄50 split.