How many people must be in a room before two of them probably share a birthday? Guess, then watch the room fill.
The birthday paradox
People with random birthdays walk into a room (seed 1200); 365 equally likely days.
People walk into a room one at a time, each with a random birthday. A line joins every pair: each pair could share a birthday.
Predict first. How many people must be in a room before two probably share a birthday?
Describe this picture
Two panels, side by side on a wide screen and stacked on a phone. One is a ring where people appear as dots, one at a time, each with a birthday drawn at random (seed 1200). Every pair of people is joined by a faint line, and when two people share a birthday, both dots and their line light up in colour, with the people’s numbers beside them; the room waits a moment after each, and the caption names the pair. In this room, person 20 shares a birthday with person 15, and person 23 with person 22. The other panel is a curve of the exact chance that at least two people share a birthday against the number of people, from 0 to 60, climbing from 0 towards 1, with a dashed level at one half labelled “more likely than not” and a marker at the present count. Before the clip, a question asks how many people it takes for a shared birthday to be more likely than not, with three drawings: about 180, about 60 and about 23; a tap picks one and starts the clip. Your guess is drawn as a dotted vertical line on the curve, or, for 180, as an arrow past the right edge. The clip fills the room to 23 people. Readouts give people, pairs and the chance. After the clip a slider, “People in the room”, sets the number from 2 to 60.
Counting pairs
Most people guess far too high. The answer is 23: in a room of 23 people, a shared birthday is slightly more likely than not, with a chance of 0.507.
The usual mistake is to think about your own birthday: how many people would it take for someone to share mine? That needs a lot of people. But the question is about any two people in the room, and that is a question about pairs.
Watch the lines in the room. With 23 people, each person can pair with 22 others. That counts every pair twice, once from each end, so there are
pairs. Each of them is a chance for a shared birthday.
After the clip, drag the number of people and watch the pairs readout. Double the people and the pairs roughly quadruple: 10 people make 45 pairs, 20 make 190, 40 make 780.
To get the exact chance, I need to count carefully. That takes two tools.
The multiplication rule
A bike lock has 4 dials, and you set a code with 4 different digits, 0 to 9. How many codes are there? The first digit can be any of 10. Whatever it was, the second can be any of the 9 left, then 8, then 7:
This is the multiplication rule: when a choice is made in steps, and each step has the same number of options whatever came before, multiply the numbers of options.
Arranging all things of a set in a row gives orders. This product is written and read ” factorial”; and . By agreement .
Arranging only of the things, in order, stops the product after steps:
The lock’s codes are .
Order, or no order
Now choose a committee of 3 people from 8. A committee has no first or second member: Ana, Ben, Cai is the same committee as Cai, Ana, Ben.
Count in order first: ordered lists. Each committee of 3 shows up in of them, once for each order of its members. So the number of committees is .
The number of ways to choose things from , when order does not matter, is the binomial coefficient, read ” choose ”:
The stops the ordered count after steps, and the removes the orders.
There is a second way to build these numbers. Pick one of the people, say Ana. Every committee of either includes Ana, and then picks more from the other , or it leaves Ana out and picks all from the other :
Write the numbers in rows, row holding to , and each number is the sum of the two above it. This is Pascal’s triangle.
In signal processing · repeated convolution
Row of the triangle holds the coefficients of : . Each row is the row above convolved with , the “add the two above” rule written as a convolution. Sums of random variables uses the same step to add dice.
The birthday product
Back to the room. I assume every person’s birthday is one of 365 days, each as likely as the others, and that nobody’s birthday depends on anyone else’s. So I ignore 29 February and twins.
Line the people up and write down their birthdays in order. By the multiplication rule there are such lists, all equally likely. In how many do all the birthdays differ? The first person can have any of 365 days, the second any of the other 364, and so on:
The chance that no two of the people share a birthday is the share of lists with all birthdays different:
The symbol means “multiply together”, as means “add together”. By the complement rule of What probability measures, the chance of at least one shared birthday is .
For 23 people this is 0.507, and for 22 it is 0.476. So 23 is the smallest room where a shared birthday is more likely than not.
A check with pairs. Each of the 253 pairs shares a birthday with chance . So over many rooms of 23, there are on average shared pairs per room, close to one. If the pairs could not affect each other, the chance that none of them matched would be , a match chance of . That is close to the exact 0.507; the pairs share people, so they are not quite separate.
Worked example
1. Codes. A code of 4 different digits: codes. Allow repeated digits and every dial has 10 options: codes.
2. A lottery. Choose 6 numbers from 1 to 49; the order of the draw does not matter.
One ticket wins with chance , about one in 14 million.
3. Rooms of different sizes. The birthday product, worked out for a few rooms:
| People | Pairs | Chance of a shared birthday |
|---|---|---|
| 5 | 10 | 0.0271 |
| 10 | 45 | 0.1169 |
| 22 | 231 | 0.4757 |
| 23 | 253 | 0.5073 |
| 50 | 1225 | 0.9704 |
| 57 | 1596 | 0.9901 |
With 57 people a shared birthday is 99 % likely. It becomes certain only at 366 people: with 366 people and 365 days, two must share.
Try it yourself. A poker hand is 5 cards from 52, with order not mattering. There are hands.
Where you’ll meet this
Hash collisions. A computer often files items by a short code computed from each one, a hash. A 32-bit hash has , about 4.3 billion, possible codes. By the same count as for birthdays, two items are more likely than not to share a code after only about 77 000 items. Programs that rely on hashes are designed for that, not for the 4.3 billion.
The rule of thumb behind this works for any number of codes: a shared code becomes likely once the number of pairs reaches about 0.693 times (that is, times) the number of codes. For birthdays that is pairs, 23 people.
Lotteries, codes and passwords. The size of a lottery, a PIN or a password space is a count by the multiplication rule or a binomial coefficient. Each extra character multiplies the number of passwords an attacker must try.
Choosing teams and samples. The number of ways to pick a team, a jury or a survey sample is a binomial coefficient. It returns in Discrete random variables, where it counts the ways to get heads in flips.
Reference card
| Quantity | Formula | Notes |
|---|---|---|
| Multiplication rule | multiply the options at each step | same number of options whatever came before |
| All in a row | ||
| of , in order | codes with different digits | |
| of , no order | committees, hands, tickets | |
| Pascal’s rule | each entry is the sum of the two above | |
| Pairs among | 253 for 23 people | |
| No shared birthday among | shared: one minus this; 0.507 at 23 |