# 贈券收集問題

## 解答

### 計算期望值

\begin{align} \operatorname{E}(T)& = \operatorname{E}(t_1) + \operatorname{E}(t_2) + \cdots + \operatorname{E}(t_n) = \frac{1}{p_1} + \frac{1}{p_2} + \cdots + \frac{1}{p_n} \\ & = \frac{n}{n} + \frac{n}{n-1} + \cdots + \frac{n}{1} = n \cdot \left(\frac{1}{1} + \frac{1}{2} + \cdots + \frac{1}{n}\right) \, = \, n \cdot H_n. \end{align}

$\operatorname{E}(T) = n \cdot H_n = n \ln n + \gamma n + \frac1{2} + o(1), \ \ \text{as} \ n \to \infty,$

$\operatorname{P}(T \geq c \, n H_n) \le \frac1c.$

### 變異

\begin{align} \operatorname{Var}(T)& = \operatorname{Var}(t_1) + \operatorname{Var}(t_2) + \cdots + \operatorname{Var}(t_n) \\ & = \frac{1-p_1}{p_1^2} + \frac{1-p_2}{p_2^2} + \cdots + \frac{1-p_n}{p_n^2} \\ & \leq \frac{n^2}{n^2} + \frac{n^2}{(n-1)^2} + \cdots + \frac{n^2}{1^2} \\ & \leq n^2 \cdot \left(\frac{1}{1^2} + \frac{1}{2^2} + \cdots \right) = \frac{\pi^2}{6} n^2 \le 2 n^2, \end{align}

$\operatorname{P}\left(|T- n H_n| \geq c\, n\right) \le \frac{2}{c^2}.$

### 尾部估算

\begin{align} P\left [ {Z}_i^r \right ] = \left(1-\frac{1}{n}\right)^r \le e^{-r / n} \end{align}

\begin{align} P\left [ T > \beta n \log n \right ] \le P \left [ \bigcup_i {Z}_i^{\beta n \log n} \right ] \le n \cdot P [ {Z}_1 ] \le n^{-\beta + 1} \end{align}

### 用生成函數的解法

• 收集第一張贈券，其出現的機率是$n/n=1$
• 收集了若干張第一種贈券
• 收集到一張第二種贈券，其出現的機率是$(n-1)/n$
• 收集了若干張第一種或第二種贈券
• 收集到一張第三種贈券，其出現的機率是$(n-2)/n$
• 收集了若干張第一種、第二種或第三種贈券
• 收集到一張第四種贈券，其出現的機率是$(n-3)/n$
• $\ldots$
• 收集到一張最後一種贈券，其出現的機率是$1/n$

$G(z)=\sum_{m=0}^\infty p^mz^m = 1 + p z + p^2 z^2 + p^3 z^3 + \cdots = \frac{1}{1 - p z}$

$G(z) = \frac{n}{n} z \cdot \frac{1}{1-\frac{1}{n} z} \cdot \frac{n-1}{n} z \cdot \frac{1}{1-\frac{2}{n} z} \cdot \frac{n-2}{n} z \cdot \frac{1}{1-\frac{3}{n} z} \cdot \frac{n-3}{n} z \cdots \frac{1}{1-\frac{n-1}{n} z} \cdot \frac{n-(n-1)}{n} z.$

$\operatorname{E}(T) = \left. \frac{\mathrm{d}}{\mathrm{d}z} G(z) \right|_{z=1}$

$\Pr(T=k) = \left.\frac{1}{k!}\frac{\mathrm{d}^kG(z)}{\mathrm{d}z^k}\right|_{z=0}$

$G(z) = z^n \frac{n-1}{n-z} \frac{n-2}{n-2z} \frac{n-3}{n-3z} \cdots \frac{n-(n-1)}{n-(n-1)z}$

$\frac{\mathrm{d}}{\mathrm{d}z} \frac{n-k}{n-kz} = \frac{k(n-k)}{(n-kz)^2}$

$\frac{\mathrm{d}}{\mathrm{d}z} G(z) = G(z) \left( \frac{n}{z} + \frac{1}{n-z} + \frac{2}{n-2z} + \frac{3}{n-3z} \cdots + \frac{n-1}{n-(n-1)z} \right)$

\begin{align} \operatorname{E}(T) &= \left. \frac{\mathrm{d}}{\mathrm{d}z} G(z) \right|_{z=1}\\ &= G(1) \left( n + \frac{1}{n-1} + \frac{2}{n-2} + \frac{3}{n-3} \cdots + \frac{n-1}{n-(n-1)} \right) \\ &= n + \sum_{k=1}^{n-1} \frac{k}{n-k} \end{align}

$\sum_{k=1}^{n-1} \frac{k}{n-k} = \sum_{k=1}^{n-1} \left( \frac{k}{n-k} - \frac{n}{n-k} \right) + n H_{n-1} = n H_{n-1} - (n-1)$

$\operatorname{Var}(T) = \operatorname{E}(T(T-1)) + \operatorname{E}(T) - \operatorname{E}(T)^2$

\begin{align} \operatorname{E}(T(T-1)) =& \left. \frac{\mathrm{d}^2}{\mathrm{d}z^2} G(z) \right|_{z=1}\\ =& \left[ G(z) \left( \frac{n}{z} + \frac{1}{n-z} + \frac{2}{n-2z} + \frac{3}{n-3z} \cdots + \frac{n-1}{n-(n-1)z} \right)^2 \right. \\ & \;\left.\left. + G(z) \left( - \frac{n}{z^2} + \frac{1^2}{(n-z)^2} + \frac{2^2}{(n-2z)^2} + \frac{3^2}{(n-3z)^2} \cdots + \frac{(n-1)^2}{(n-(n-1)z)^2} \right) \right]\right|_{z=1}\\ =& n^2 H_n^2 - n + \sum_{k=1}^{n-1} \frac{k^2}{(n-k)^2} \\ =& n^2 H_n^2 - n + \sum_{k=1}^{n-1} \frac{(n-k)^2}{k^2} \\ =& n^2 H_n^2 - n + n^2 H_{n-1}^{(2)} - 2 n H_{n-1} + (n-1). \end{align}

\begin{align} \operatorname{Var}(T) & = \; n^2 H_n^2 - 1 + n^2 H_{n-1}^{(2)} - 2 n H_{n-1} + n H_{n-1} + 1 - n^2 H_n^2 \\ & = \; n^2 H_{n-1}^{(2)} - n H_{n-1} < \frac{\pi^2}{6} n^2 \end{align}

## 參考文獻

• Paul Erdős and Alfréd Rényi, On a classical problem of probability theory, Magyar Tud. Akad. Mat. Kutato Int. Kozl, 1961.
• William Feller, An introduction to Probability Theory and its Applications, 1957.
• Michael Mitzenmacher and Eli Upfal, Probability and Computing: Randomized Algorithms and Probabilistic Analysis, Cambridge University Press, 2005
• Donald J. Newman and Lawrence Shepp, The Double Dixie Cup Problem, American Mathematical Monthly, Vol. 67, No. 1 (Jan., 1960), pp. 58–61.
• Philippe Flajolet, Danièle Gardy, Loÿs Thimonier Birthday paradox, coupon collectors, caching algorithms and self-organizing search., Discrete Applied Mathematics, Vol. 39, (1992), pp. 207–229