# How many times should I roll a die to get 4 different results?

What is the expected value of the number $X$ of rolling a die until we obtain 4 different results (for example, $X=6$ in case of the event $(1,4,4,1,5,2)$)?

I'm not only interested in technical details of a solution---I can solve it to some extent, see below---but even more in the following:

1. Is it a known problem, does it have a name?
2. Does there exist a closed-form expression? (See below for a series expansion)
3. Does there exist a feasible algorithm/formula to compute it if the die is not "fair" and each face has possibly a different probability?

My attempt: $EX=\sum_{j=4}^\infty j\, P(X=j)$. Clearly, $P(X=j)$ is $1/6^j$ multiplied by the number of ways to obtain $X=j$. The number of ways is $6\choose 3$ (the choice of 3 elements that occur within the first $j-1$ rolls) multiplied by $3$ (the last roll) multiplied by the number of surjective functions from $j-1$ to 3 (the number of ways what can happen in the first $j-1$ rolls, if the three outputs are given). Further, the number of surjective functions can be expressed via Stirling numbers of the second kind: so in this way, I can get a series expression, although not a very nice one.

-

This is essentially the collector's problem.

You want to model each unique face as a geometric distribution. $X_i\sim\text{Geom}\left(p = \frac{7-i}{6}\right)$ on $\{1,2,3,\dotsc\}$ for $i = 1,2,3,4$ denotes the number of rolls until the $i$th unique face. In the typical collector's problem, we are interested in $i$ from $1$ to $6$ (all faces). So $X = X_1+\dotsb+X_4$ denotes the number of rolls until you see four distinct faces. Thus $$E[X] = E[X_1+\dotsb+X_4] = \frac{6}{6}+\frac{6}{5}+\frac{6}{4}+\frac{6}{3} = 57/10,$$ which means it will take you about 5.7 rolls.

-
Thank you. Do you know if, in case of different probabilities, something better can be done then summing over all possibilities? – Peter Franek Jan 13 at 21:18
@PeterFranek No, not at the moment. All I can think of is adding over all possibilities. Sorry about that. – probablyme Jan 13 at 21:21

You do not need the probabilities to calculate the expected value of $X$.

The probability to get another number is $\frac{6}{6}$ , $\frac{5}{6}$ , $\frac{4}{6}$ and $\frac{3}{6}$ , if $0,1,2,3$ numbers have already appeared.

So, $E(X)=\frac{6}{6}+\frac{6}{5}+\frac{6}{4}+\frac{6}{3}=5.7$

So, with a $6$-sided dice, to get $4$ numbers, you need $5.7$ throws in the average.

If you throw until all numbers appear, you have the coupon-collector-problem. You can calculate other values in an analogue way.

I assumed equal probabilities. If this is not the case, the solution is far more difficult.

-
Thank you, I didn't realize that it's that easy. Could you give me a hint on the un-equal probabilities case? Is the only chance to sum over everything that can happen? – Peter Franek Jan 13 at 21:17
I do not have a better idea, but at least, it will work! But you have to consider that the probability for the next number depends on the numbers which have already appeared. This won't be that easy. I guess you have to go through the possible permutations ($720$ in the case of $6$ sides) and take the average of all the expectations arising from the particular permutation. – Peter Jan 13 at 21:35
Thank you. As strange as it sounds, I really need to calculate it. I will at least try some approximation... – Peter Franek Jan 13 at 21:37
A warning : I am not sure whether the average over the $n!$ expectations gives the right result. – Peter Jan 13 at 21:47
I will think about it, you gave me good hints. But if you would have something more concrete in mind, please don't hesitate to extend your answer (although I already accepted the other answer, will give you a 100 points bounty if you help) :) – Peter Franek Jan 13 at 21:52