Coupon collector

FreeProbabilityEasyJane StreetSIGFive Rings

How many rolls of a fair NN-sided die are required, on average, to observe every face at least once? Compute the value for N=100N = 100, rounded to the nearest integer.

Solution

Coupon Collector's Problem

High-level idea. Decompose the total waiting time into independent geometric stages, then apply linearity of expectation.

Stage decomposition

Let TT be the total number of rolls of a fair NN-sided die needed to observe every face at least once. Define stage kk (k=1,,Nk = 1, \ldots, N) as the period that begins the moment the (k1)(k{-}1)-th distinct face was first seen and ends when the kk-th distinct face is first seen. Writing TkT_k for the number of rolls in stage kk,

T=T1+T2++TN.T = T_1 + T_2 + \cdots + T_N.

Distribution of each stage

At the start of stage kk, exactly k1k-1 faces have been observed. Each roll independently reveals a previously unseen face with probability

pk=N(k1)N=Nk+1N.p_k = \frac{N-(k-1)}{N} = \frac{N-k+1}{N}.

Hence TkGeometric(pk)T_k \sim \operatorname{Geometric}(p_k) (number of trials until first success), so

E[Tk]=1pk=NNk+1.E[T_k] = \frac{1}{p_k} = \frac{N}{N-k+1}.

Closed-form expected value

By linearity of expectation,

E[T]=k=1NNNk+1.E[T] = \sum_{k=1}^{N} \frac{N}{N-k+1}.

Reindexing with j=Nk+1j = N-k+1 (as kk runs 1N1 \to N, jj runs N1N \to 1):

E[T]=Nj=1N1j=NHN,E[T] = N \sum_{j=1}^{N} \frac{1}{j} = N \cdot H_N,

where HN=j=1N1jH_N = \displaystyle\sum_{j=1}^{N} \frac{1}{j} is the NN-th harmonic number.

Numerical evaluation for N=100N = 100

Using the Euler–Maclaurin asymptotic expansion

HN=lnN+γ+12N112N2+1120N4,H_N = \ln N + \gamma + \frac{1}{2N} - \frac{1}{12N^2} + \frac{1}{120N^4} - \cdots,

with γ=0.57721566490153\gamma = 0.57721566490153\ldots (Euler–Mascheroni constant):

H1004.60517018598809ln100+0.57721566490153γ+0.005000000000001/2000.000008333331/1200005.18737752.\begin{aligned} H_{100} &\approx \underbrace{4.60517018598809}_{\ln 100} + \underbrace{0.57721566490153}_{\gamma} + \underbrace{0.00500000000000}_{1/200} - \underbrace{0.00000833333}_{1/120000} \\ &\approx 5.18737752. \end{aligned}

Therefore,

E[T]N=100=100×H100518.74.E[T]\big|_{N=100} = 100 \times H_{100} \approx 518.74.

Rounded to the nearest integer:

519.\boxed{519}.

Related problems