Birthday Paradox: Why 23 People Is Enough

simulator beginner ~8 min
Loading simulation...
P ≈ 50.7% — the paradox threshold

With 23 people, the probability of at least one shared birthday is about 50.7%. This feels wrong because we think about specific dates, but there are 253 possible pairs to compare.

Formula

P(match) = 1 - ∏(i=0 to n-1) (D-i)/D where D = days in year
P(match) ≈ 1 - e^(-n(n-1)/(2D)) — approximation for large D

The Most Surprising Number in Probability

How many people do you need in a room for there to be a 50% chance that two of them share a birthday? Most people guess around 183 — half of 365. The real answer is just 23. This stunning result, known as the birthday paradox, reveals how poorly our intuitions handle combinatorial probability. It's not really a paradox — it's just deeply counterintuitive.

Why Pairs Matter More Than People

The key insight is that we're not asking whether anyone shares your birthday — we're asking whether any two people share any birthday. With 23 people, there are C(23,2) = 253 possible pairs. Each pair has a 1/365 chance of matching, and these 253 opportunities compound rapidly. The probability of no match at all is (365/365)(364/365)(363/365)...(343/365) ≈ 0.493, so the probability of at least one match is about 50.7%.

Running the Simulation

The simulation generates random birthdays for each person in the group and checks for matches. The circular calendar display shows where birthdays fall throughout the year, with matching dates highlighted in red. Run thousands of simulations to verify that the empirical probability converges to the theoretical value. Try increasing the group size to see how quickly the probability approaches 100%.

Applications Beyond Birthdays

The birthday paradox has profound implications in computer science and cryptography. The birthday attack on hash functions exploits the same mathematics: finding two inputs that produce the same hash output requires only about √(2^n) = 2^(n/2) attempts for an n-bit hash. This is why cryptographic hash functions must be at least 256 bits to provide 128 bits of collision resistance.

FAQ

Why is the birthday paradox surprising?

People intuitively estimate the probability that someone shares their specific birthday (≈ n/365), which is low. But the paradox asks about any pair sharing any birthday. With 23 people there are C(23,2) = 253 pairs, and the probability accumulates rapidly across all these comparisons.

What is the exact probability for 23 people?

The exact probability is 1 - (365/365)(364/365)(363/365)...(343/365) ≈ 0.5073. Each factor represents the probability that the next person has a unique birthday, and their product gives the probability of no matches.

How is the birthday paradox used in cryptography?

The birthday attack exploits this principle to find hash collisions. For an n-bit hash, you only need about 2^(n/2) attempts to find two inputs with the same hash — much fewer than the 2^n you might expect. This is why hash functions need to be at least twice as long as the desired security level.

Does the birthday paradox assume uniform distribution?

The classical calculation assumes birthdays are uniformly distributed across the year. In reality, birthdays cluster around certain months, which actually increases the collision probability — making the paradox even more pronounced in practice.

Sources

Embed

<iframe src="https://homo-deus.com/lab/probability/birthday-paradox/embed" width="100%" height="400" frameborder="0"></iframe>
View source on GitHub