# The probability mass function of X is times of rolling a dice until all sides appear at least once

probabilityrandom variables

Suppose that X is the number of times that we roll a dice until each side of the dice appears at once. I want to find its probability mass function and since X is a discrete random variable, $$f(x) = P(X=x)$$. So I need to find the probability of each number of X. And X can be 6,7,8,…
$$P(X=6)$$ means we rolled the dice 6 times and all numbers appeared. so the probability is $$\frac{6!}{6^6}$$. But for other numbers of X it gets complicated. For example for $$X=7$$ it means that at the 6 first rolls, a number appeared twice. $$P(X=7)=6 \times 5 \times \frac{5!}{2!} \times \frac{1}{6^7}$$. And for higher numbers of X we must consider more conditions. Can some one help?

The last throw must be the sixth number. So if there are $$~n (\geq 6) ~$$ throws, first $$~(n-1)~$$ throws must be consisting of five numbers and all five numbers must appear at least once. One of the ways is to apply Principle of Inclusion Exclusion or we can use Stirling Number of the second kind.
We first choose $$5$$ numbers out of $$6$$ that appear in first $$(n-1)$$ throws. We then use Stirling Number of the second kind that gives us $$5$$ non-empty heaps that sum to $$(n-1)$$ distinct throws. Finally we multiply by $$5!$$ to assign $$5$$ chosen numbers to the heaps.
So $$\displaystyle P(X = n) = {6 \choose 5} \cdot 5! \cdot StirlingS2[n-1,5] ~/ ~6^n$$