Problem. Suppose there are $n$ distinct types of coupons in unlimited supply, and each draw yields any type with equal probability $1/n$. On average, how many draws are needed to collect all $n$ types?
Solution
We want the expected number of draws required to collect all $n$ types of coupons.
Let $T$ be the total number of draws needed, and let $t_i$ be the number of draws required to obtain a new ($i$-th distinct) type after $i - 1$ distinct types have already been collected.
Then $T = \sum_{i=1}^{n} t_i$, where $t_1, t_2, \dots, t_n$ are independent random variables with $t_i \sim \operatorname{Geom}(p_i)$ and $p_i = \frac{n - i + 1}{n}$. By linearity of expectation,
$$\mathbb{E}[T] = \sum_{i=1}^{n} \mathbb{E}[t_i] = \sum_{i=1}^{n} \frac{1}{p_i} = \frac{n}{n} + \frac{n}{n - 1} + \cdots + \frac{n}{1} = n H_n,$$where $H_n = \sum_{i=1}^{n} \frac{1}{i}$ is the $n$-th harmonic number.
Going a step further, we can compute the variance of $T$. Using independence of $t_1, \dots, t_n$:
$$ \begin{aligned} \operatorname{Var}(T) &= \sum_{i=1}^{n} \operatorname{Var}(t_i) = \sum_{i=1}^{n} \frac{1 - p_i}{p_i^2} \\ &= \sum_{i=1}^{n} \frac{n(i - 1)}{(n - i + 1)^2} = n \sum_{i=1}^{n} \frac{n - (n - i + 1)}{(n - i + 1)^2} \\ &= n \sum_{i=1}^{n} \left( \frac{n}{(n - i + 1)^2} - \frac{1}{n - i + 1} \right) \\ &= n^2 \sum_{j=1}^{n} \frac{1}{j^2} - n \sum_{j=1}^{n} \frac{1}{j} \\ &= n^2 H_n^{(2)} - n H_n, \end{aligned} $$where $H_n^{(2)} = \sum_{j=1}^{n} \frac{1}{j^2}$ is the $n$-th generalized harmonic number of order $2$.
Generalizations
Generalization 1: Drawing Multiple Coupons at Once
We begin with a useful combinatorial identity.
Lemma. Prove that
$$\sum_{k=1}^{n} (-1)^{k+1} \frac{1}{k} C_n^k = 1 + \frac{1}{2} + \cdots + \frac{1}{n}.$$
Proof. For $1 \le k \le n - 1$, Pascal’s identity gives
$$\frac{1}{k} C_n^k = \frac{1}{k}\left(C_{n-1}^k + C_{n-1}^{k-1}\right) = \frac{1}{k} C_{n-1}^k + \frac{1}{n} C_n^k.$$Let $f_n = \sum_{k=1}^{n} (-1)^{k+1} \frac{1}{k} C_n^k$. Then for $n \ge 2$,
$$ \begin{aligned} f_n &= \sum_{k=1}^{n-1} (-1)^{k+1} \frac{1}{k} C_n^k + (-1)^{n+1} \frac{1}{n} \\ &= \sum_{k=1}^{n-1} (-1)^{k+1} \frac{1}{k} C_{n-1}^k + \frac{1}{n} \sum_{k=1}^{n-1} (-1)^{k+1} C_n^k + (-1)^{n+1} \frac{1}{n} \\ &= f_{n-1} + \frac{1}{n} \sum_{k=1}^{n} (-1)^{k+1} C_n^k \\ &= f_{n-1} + \frac{1}{n}. \end{aligned} $$The final equality holds because
$$\sum_{k=1}^{n} (-1)^{k+1} C_n^k = \sum_{k=0}^{n} (-1)^{k+1} C_n^k + C_n^0 = C_n^0 - \sum_{k=0}^{n} (-1)^k C_n^k = 1 - (1 - 1)^n = 1.$$Since $f_n = f_{n-1} + \frac{1}{n}$ and $f_1 = 1$, it follows by induction that $f_n = 1 + \frac{1}{2} + \cdots + \frac{1}{n}$. $\square$
Now consider the generalized problem:
Problem. Suppose there are $n$ distinct types of coupons in unlimited supply, each equally likely to appear. If each draw yields a pack of $t$ distinct coupons ($1 \le t \le n$) chosen uniformly at random, what is the expected number of draws required to collect all $n$ types?
Solution. Let $A_{k,i}$ be the event that the $i$-th coupon type has not been obtained after $k$ draws, and let $T$ be the number of draws required. By the inclusion-exclusion principle,
$$ \begin{aligned} P(T > k) &= P\left(\bigcup_{i=1}^{n} A_{k,i}\right) \\ &= \sum_{i=1}^{n} P(A_{k,i}) - \sum_{1 \le i < j \le n} P(A_{k,i} \cap A_{k,j}) + \cdots + (-1)^{n+1} P\left(\bigcap_{i=1}^{n} A_{k,i}\right). \end{aligned} $$For any $r$ distinct coupon types $i_1 < i_2 < \cdots < i_r$ ($1 \le r \le n$), avoiding all $r$ of them in a single pack of $t$ coupons has probability $C_{n-r}^t / C_n^t$ (with the convention $C_m^t = 0$ for $m < t$, and $0^0 = 1$ at $k = 0$). Across $k$ independent draws,
$$P\left(\bigcap_{s=1}^{r} A_{k, i_s}\right) = \left(\frac{C_{n-r}^t}{C_n^t}\right)^k, \quad 1 \le r \le n.$$Substituting this into the inclusion-exclusion formula gives
$$P(T > k) = \sum_{r=1}^{n} (-1)^{r+1} C_n^r \left(\frac{C_{n-r}^t}{C_n^t}\right)^k.$$Using the tail-sum formula for non-negative integer-valued random variables,
$$ \begin{aligned} \mathbb{E}[T] &= \sum_{k=0}^{\infty} P(T > k) = \sum_{k=0}^{\infty} \sum_{r=1}^{n} (-1)^{r+1} C_n^r \left(\frac{C_{n-r}^t}{C_n^t}\right)^k \\ &= \sum_{r=1}^{n} (-1)^{r+1} C_n^r \sum_{k=0}^{\infty} \left(\frac{C_{n-r}^t}{C_n^t}\right)^k \\ &= \sum_{r=1}^{n} (-1)^{r+1} C_n^r \frac{1}{1 - C_{n-r}^t / C_n^t}. \end{aligned} $$As a sanity check, when $t = 1$ we have $1 - C_{n-r}^1 / C_n^1 = r / n$, so by the lemma above,
$$ \begin{aligned} \mathbb{E}[T] &= \sum_{r=1}^{n} (-1)^{r+1} \frac{n}{r} C_n^r = n \sum_{r=1}^{n} (-1)^{r+1} \frac{1}{r} C_n^r \\ &= n\left(1 + \frac{1}{2} + \cdots + \frac{1}{n}\right) = n H_n, \end{aligned} $$which recovers the classic result.
Generalization 2: Unequal Probabilities
Problem. Suppose there are $n$ distinct types of coupons, with $a_i > 0$ copies of the $i$-th type. On each draw, one coupon is selected uniformly at random and then replaced. What is the expected number of draws needed to collect all $n$ types?
Solution. Let $p_i = \frac{a_i}{\sum_{j=1}^{n} a_j}$ ($i = 1, 2, \dots, n$) be the probability of drawing the $i$-th coupon type on any given draw, so that $\sum_{i=1}^{n} p_i = 1$. As before, let $A_{k,i}$ be the event that the $i$-th type has not appeared in the first $k$ draws, and let $T$ be the total number of draws needed.
By inclusion-exclusion,
$$ \begin{aligned} P(T > k) &= P\left(\bigcup_{i=1}^{n} A_{k,i}\right) \\ &= \sum_{i=1}^{n} P(A_{k,i}) - \sum_{1 \le i < j \le n} P(A_{k,i} \cap A_{k,j}) + \cdots + (-1)^{n+1} P\left(\bigcap_{i=1}^{n} A_{k,i}\right). \end{aligned} $$For any $1 \le i_1 < i_2 < \cdots < i_r \le n$, avoiding all $r$ types in a single draw has probability $1 - \sum_{s=1}^{r} p_{i_s}$, so across $k$ independent draws,
$$P\left(\bigcap_{s=1}^{r} A_{k, i_s}\right) = \left(1 - \sum_{s=1}^{r} p_{i_s}\right)^k.$$Therefore,
$$ \begin{aligned} \mathbb{E}[T] &= \sum_{k=0}^{\infty} P(T > k) \\ &= \sum_{k=0}^{\infty} \sum_{r=1}^{n} (-1)^{r+1} \sum_{1 \le i_1 < \cdots < i_r \le n} \left(1 - \sum_{s=1}^{r} p_{i_s}\right)^k \\ &= \sum_{r=1}^{n} (-1)^{r+1} \sum_{1 \le i_1 < \cdots < i_r \le n} \sum_{k=0}^{\infty} \left(1 - \sum_{s=1}^{r} p_{i_s}\right)^k \\ &= \sum_{r=1}^{n} (-1)^{r+1} \sum_{1 \le i_1 < \cdots < i_r \le n} \frac{1}{p_{i_1} + p_{i_2} + \cdots + p_{i_r}}. \end{aligned} $$