Problem. There are distinct coupon types. Each purchase yields a uniformly random type. How many purchases are needed to collect all ?
The answer
with (the Euler-Mascheroni constant).
The derivation β by linearity
Split the process into phases: phase runs from having distinct coupons to having .
In phase , a purchase is βnewβ with probability , so the expected length of that phase is (a geometric random variable). By linearity of expectation:
double couponCollector(int n) {
double e = 0;
for (int i = 1; i <= n; i++) e += 1.0 / i;
return n * e;
}| 6 (a die) | 14.7 |
| 52 (a deck) | 236 |
| 100 | 519 |
| 365 | 2 364 |
| 1000 | 7 486 |
Concentration
so the collection time is sharply concentrated around . Being twice the mean is already exponentially unlikely. The variance is , so the standard deviation is β small relative to the mean .
Variants
| Variant | Expected purchases |
|---|---|
| Collect all | |
| Collect of | |
| Collect copies of each | |
| Non-uniform probabilities | β no simple closed form |
| Buy in packs of distinct coupons | roughly |
| Expected distinct coupons after purchases | |
| Probability all collected by time | inclusion-exclusion: |
The expected distinct after draws formula is the one that appears most in problems β it is the βballs into binsβ occupancy result, and it follows from linearity again (each coupon is missing with probability ).
The contrast with the birthday paradox
Two questions about the same process, with very different answers:
| Question | Threshold |
|---|---|
| When does the first collision occur? | draws (birthday) |
| When are all values seen? | draws (coupon collector) |
versus β the two ends of the same occupancy process, and worth keeping straight. Collisions start almost immediately; completion takes far longer than the naive .
Where it appears in algorithms
| Setting | Coupon collector bound |
|---|---|
| Randomised algorithms needing every element sampled | rounds |
| Random walks covering a graph | the cover time β for a complete graph |
| Hashing: rounds until every bucket is hit | |
| Randomised load balancing | related occupancy bounds |
| Testing: random inputs to hit every branch | |
| Random restarts until every basin is tried | |
| Gossip / epidemic protocols | rounds to inform everyone |
Cover time is the natural generalisation: the expected time for a random walk to visit every vertex. It is for the complete graph, for a path or cycle, and for any connected graph (Aleliunas et al.).
The factor is unavoidable
The is not an artefact of the analysis. With draws for a constant , the probability that a specific coupon is still missing is , so about coupons remain β which only reaches when .
Why it is worth knowing
It is the cleanest application of linearity of expectation over phases, and the answer is a bound that appears whenever a randomised process must touch every element. Paired with the birthday , it gives you the two ends of the occupancy spectrum, which covers most probabilistic estimates you will need.
See also: Expected Value Techniques Β· Birthday Paradox Β· Probability