Each draw picks one of n classes uniformly at random with replacement. What is the expected number of draws until every class has appeared at least once, and what is it for n=6 and for n=100?

Probability and statistics, Expectation and variance
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can split the waiting time into stages, recognise each as a geometric random variable, and use linearity of expectation.

Key idea

The total time is T=∑i=1nTi, where Ti is geometric with success probability n−i+1n, so E[T]=n∑k=1n1k=nHn≈n(ln⁡n+γ)+12.

Steps

  1. Split the process into stages. Stage i starts when i−1 distinct classes have been seen and ends when the ith new class appears. Let Ti be the number of draws in stage i.
  2. In stage i there are n−(i−1) unseen classes, so each draw is a success with probability pi=n−i+1n. Hence Ti is geometric with mean E[Ti]=1/pi=nn−i+1.
  3. By linearity of expectation (no independence needed): E[T]=∑i=1nnn−i+1=n∑k=1n1k=nHn, where Hn is the nth harmonic number.
  4. For n=6 (a die): H6=1+12+13+14+15+16=2.45, so E[T]=6×2.45=14.7 rolls.
  5. For large n use Hn≈ln⁡n+γ+12n with γ≈0.5772 (Euler's constant). For n=100: E[T]≈100(4.605+0.577)+0.5=518.7. The exact value is also 518.7.
  6. Meaning: seeing every class needs about nln⁡n draws, which is ln⁡n times more than n. This matters for random sampling with replacement: a mini-batch scheme needs about nln⁡n draws, not n, before every example has been visited.

Common mistakes

How long your answer should be

Half a page; 4 minutes.

Last checked on 4 December 2026.

Read this

Previous in Probability and statistics: How do you prove the weak law of large numbers for i.i.d. random variables with mean μ and finite variance σ2, using Chebyshev's inequality? If σ2=4, how many samples guarantee P(∣Xˉn−μ∣≥0.5)≤0.01?
Next in Probability and statistics: Show that an estimator whose bias and variance both tend to 0 is consistent. For i.i.d. X1,…,Xn∼N(μ,σ2) with σ2=4, what are an unbiased but inconsistent and a biased but consistent estimator of μ, and for n=10, how do the mean squared errors (MSE) of the divide-by-n and divide-by-(n−1) estimators of σ2 compare?