1. The problem
n guests leave their hats at a cloakroom. At the end of the evening the attendant, having lost all the tokens, hands the hats back completely at random. What is the chance that nobody gets their own hat back?
Intuition pulls two ways: with more guests each person is less likely to get their hat, but there are also more people who might.
2. The answer
3. Working it out
An arrangement where nobody gets their own item is called a derangement. Count them with inclusion–exclusion: start with all n! orders, remove those where guest 1 is matched, guest 2 is matched…, add back the double removals, and so on:
The series converges ridiculously fast: from n = 7 onward the answer agrees with 1/e to four decimal places. The number of matches follows (nearly) a Poisson distribution with mean 1.
| Guests n | Derangements Dn | All orders n! | P(nobody matched) |
|---|
4. Hand back the hats
Evenings: 0 · nobody matched: 0 → – · average matches: –
How many guests got their own hat
■ simulated ● exact
5. Fine print
- Same maths: a Secret Santa draw where nobody draws themselves succeeds about 37 % of the time — re-draw about 2.7 times on average.
- Pierre Rémond de Montmort posed it in 1708 as the card game Treize; it was one of the first problems to bring e into probability.
- Exactly k matches has probability close to e−1/k!: one match 36.8 %, two 18.4 %, three 6.1 %.