🧮 Brain Teaser

The Matching Birthdays: Expected Collisions

A room has nn people. Each person's birthday is chosen uniformly at random from 365 days (independently). Let XX be the number of pairs of people who share a birthday.

  1. Find E[X]E[X].
  2. Use your answer to show that if n28n \geq 28, then E[X]1E[X] \geq 1, meaning we expect at least one shared birthday pair.
  3. (The surprise) The well-known birthday problem says the probability of at least one collision first exceeds 12\frac{1}{2} around n=23n = 23. How can E[X]1E[X] \geq 1 require n28n \approx 28 yet a collision becomes likely at n23n \approx 23? Reconcile this apparent contradiction.
linearity of expectationbirthday problemPoisson approximationindicator variables

Answer: The Matching Birthdays: Expected Collisions

Key Idea / Intuition

The trick is linearity of expectation: instead of tracking the complicated event "at least one pair matches," just assign each pair an indicator and sum. The expectation is clean and exact. The paradox in part (3) is resolved by recognizing that E[X]1E[X] \geq 1 and P(X1)12P(X \geq 1) \geq \frac{1}{2} are very different thresholds — expectation can be dragged above 1 by rare but large values, while probability of at least one event can exceed 12\frac{1}{2} much earlier.


Formal Proof / Solution

Part 1: Computing E[X]E[X]

There are (n2)\binom{n}{2} pairs of people. For any pair (i,j)(i,j), define the indicator

Iij=1[person i and person j share a birthday].I_{ij} = \mathbf{1}[\text{person } i \text{ and person } j \text{ share a birthday}].

The probability that two specific people share a birthday is

P(Iij=1)=3653652=1365,P(I_{ij} = 1) = \frac{365}{365^2} = \frac{1}{365},

since person jj's birthday must match person ii's (any of the 365 days), and there are 3652365^2 equally likely pairs.

By linearity of expectation:

E[X]=1i<jnE[Iij]=(n2)1365=n(n1)2365.E[X] = \sum_{1 \leq i < j \leq n} E[I_{ij}] = \binom{n}{2} \cdot \frac{1}{365} = \frac{n(n-1)}{2 \cdot 365}.

Part 2: When does E[X]1E[X] \geq 1?

n(n1)7301    n(n1)730.\frac{n(n-1)}{730} \geq 1 \iff n(n-1) \geq 730.

Check: 27×26=702<73027 \times 26 = 702 < 730 and 28×27=75673028 \times 27 = 756 \geq 730.

So E[X]1E[X] \geq 1 first holds at n=28n = 28.

Part 3: Reconciling with n=23n = 23

The confusion is between two different statements:

| Quantity | Threshold | |---|---| | P(at least one shared pair)12P(\text{at least one shared pair}) \geq \frac{1}{2} | n23n \approx 23 | | E[number of shared pairs]1E[\text{number of shared pairs}] \geq 1 | n28n \approx 28 |

These are not the same. In general, for a non-negative integer-valued random variable XX:

P(X1)E[X](by Markov’s inequality),P(X \geq 1) \leq E[X] \quad \text{(by Markov's inequality)},

but also P(X1)P(X \geq 1) can be large even when E[X]E[X] is small, if XX is concentrated near 1.

The key: when n=23n = 23, the expected number of matching pairs is

E[X]=23×227300.693<1,E[X] = \frac{23 \times 22}{730} \approx 0.693 < 1,

yet P(X1)0.507>12P(X \geq 1) \approx 0.507 > \frac{1}{2}.

This is perfectly consistent! When E[X]<1E[X] < 1, the event {X1}\{X \geq 1\} can still have probability close to E[X]E[X] (since if XX is approximately Bernoulli or Poisson(0.693)(0.693), then P(X1)=1e0.6930.5P(X \geq 1) = 1 - e^{-0.693} \approx 0.5, which matches the birthday calculation beautifully).

Intuitive summary: At n=23n=23, matching pairs are rare but not impossible — the distribution of XX is approximately Poisson with mean 0.693\approx 0.693, so the chance of zero collisions is e0.69312\approx e^{-0.693} \approx \frac{1}{2}. Expectation exceeding 1 requires the mean to grow to 1, which needs more people.

Source: Fifty Challenging Problems in Probability with Solutions (Frederick Mosteller), Problem 45 (matching), classical birthday variant

Type: ProbabilitySource: Fifty Challenging Problems in Probability with Solutions (Frederick Mosteller), Problem 45 (matching), classical birthday variantEdit on GitHub ↗