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
100519
3652 364
10007 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

VariantExpected purchases
Collect all
Collect of
Collect copies of each
Non-uniform probabilities β€” no simple closed form
Buy in packs of distinct couponsroughly
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:

QuestionThreshold
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

SettingCoupon collector bound
Randomised algorithms needing every element sampled rounds
Random walks covering a graphthe cover time β€” for a complete graph
Hashing: rounds until every bucket is hit
Randomised load balancingrelated 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