Why it happens
Why Two People in a Room Share a Birthday
With 23 people in a room, the chance two share a birthday is 50.7%, because 23 people make 253 pairs and each pair is a chance to match. By 70 people it's 99.9%. With 366 it's certain, since 365 days can't hold 366 different birthdays. That last rule is the pigeonhole principle.
A room fills until two people share a birthday
How to read the stage
- Objective
- Read the calendar, the list and the chart, and find the moment the first shared birthday appears.
- How this step gets you there
- The text names each panel and what it tracks, then points to the frame where the run stops.
People walk in one at a time. The year is a grid with a month to a row, and each person lights their birthday. Who's in the room lists them in order, and the chart marks the exact chance of a match for the room's size. The run stops at the first shared day: with seed 22, person 23 matches person 20 on August 31.
Why 23 is enough
- Objective
- Explain why the odds of a shared birthday grow with pairs, and why 23 people pass even odds.
- How this step gets you there
- The text counts the pairs and writes out the product of misses, and the stage's chart shows it crossing 50% at 23.
The question isn't whether someone matches you. It's whether any two people match, and that grows with pairs, not people: 23 people make 253 pairs. The chance nobody matches is each newcomer missing everyone inside, multiplied together: 365/365 × 364/365 × … × 343/365. That drops below a half at 23 people. At 70 it leaves a match at 99.9%.
1,000 rooms, measured
- Objective
- Compare measured rooms with the exact odds, and say how big rooms get before a match in practice.
- How this step gets you there
- The stage draws each room's first match as a bar and the share matched so far against the exact curve.
The second stage fills 1,000 seeded rooms the same way and records when each first matched. Half had matched by 23 people: 51.1% of rooms, against an exact 50.7%. The slowest room took 67 people, and none needed more than 70.
1,000 rooms, each filled until a match
When a match is certain
- Objective
- State the pigeonhole principle and apply it to birthdays, hair counts and file compression.
- How this step gets you there
- The text gives the counting argument once, then reuses it on two other examples with their numbers.
Put 366 people in a room and two must share a birthday: 365 days can't hold 366 different ones. Count February 29 and it's 367. That's the pigeonhole principle: more pigeons than holes means some hole holds two. It's why at least ten Londoners have the same number of hairs, with over 9 million people and under a million hairs each, and why no lossless compressor shrinks every file.
What the model leaves out
- Objective
- Say how real birthdays differ from the model and why the 23 and 366 figures survive the difference.
- How this step gets you there
- The text names what the even draw leaves out and what changes, and what doesn't, with real data.
The model draws every birthday evenly from the year. Real births bunch in some seasons and avoid some holidays, and twins share a day by birth. Uneven birthdays make a match a little more likely, yet real birth data still needs 23 people to pass a half. The guarantee at 366 holds whatever the odds.
Questions
- How many people do you need for two to share a birthday?
- 23 for better than even odds (50.7%), 57 for 99% and 70 for 99.9%, with birthdays spread evenly. To be certain you need 366 people, or 367 counting February 29.
- Why is it called the birthday paradox?
- It isn't a contradiction, only a surprise. People hear it as whether someone shares their own birthday, which takes 253 other people for even odds. Any two people sharing a day is far likelier, because 23 people already make 253 pairs.
- What is the pigeonhole principle?
- If more things go into fewer boxes, some box holds at least two. It's often named after Dirichlet, who used it in 1834, but a 1622 book by Jean Leurechon already argued that two men must have the same number of hairs.
- What does the birthday problem have to do with hacking?
- A hash turns any file into a short fingerprint. Finding any two files with the same fingerprint is a birthday problem, so it takes far fewer tries than matching one given fingerprint. That shortcut is called a birthday attack, and it's one reason fingerprints are made long.
Practice the pattern
Spotting the match is a seen-before check: keep a set of the days already taken and look each newcomer up. Contains Duplicate asks exactly that of an array, and a hash set answers it in one pass.