# Expected number of unique items when drawing with replacement

Having a set of size M, I'm drawing M items with replacement. What is expected number of unique items that got picked?

Thanks, Jarek

-
Tell us if you have tried something. –  leonbloy May 26 '11 at 15:51

Let $Y$ be the number of unique items that get picked. Let $X_i$ be $1$ if item $i$ gets picked and $0$ if not. We have $E[X_i] = 1 P(X_i = 1) + 0 P(X_i = 0) = P(X_i = 1) = 1 - P(X_i = 0)$. Since $P(X_i = 0)$ is the probability that item $i$ is not picked, this is the probability that $i$ is not picked with any of the first, second, third, etc., choices. Thus $P(X_i = 0) = \left(\frac{M-1}{M}\right)^M$.

Therefore, \begin{align}E[Y] &= E\left[\sum_{i=1}^M X_i\right] = \sum_{i=1}^M E[X_i] = \sum_{i=1}^M P(X_i = 1) = \sum_{i=1}^M \left(1 - \left(\frac{M-1}{M}\right)^M\right) \\ &= M - \frac{(M-1)^M}{M^{M-1}}.\end{align}

In general, using indicator functions to calculated expected values can be very helpful. For more examples, see the answers to Find the expectation or Another balls and bins question or Expected number of neighbors.

-

I just would like to add that if someone is interested in percent of picked items, then $$\frac{M - \frac{(M-1)^M}{M^{M-1}}}{M} = \frac{M - M\left(\frac{M-1}{M} \right)^M}{M} = 1 - \left(1 - \frac{1}{M} \right )^M$$
For large M it is approximately $$1 - \frac{1}{e} \simeq 0.632120559 \dots$$
$$\lim_{M\to\infty}\left(1 - \frac{1}{M} \right )^M = \frac{1}{e}$$