# Probability of getting at least 4 numbers by rolling dice n times

I want to compute probability of getting at least 4 numbers by rolling dice n times. Now my formula is

$$P = \frac{6^n - 2^n * {6 \choose 2} + 4 * 1^n * {6 \choose 1}}{6^n}$$

But by principle of exclusion and inclusion there shouldn't be 4 times of 1^n * (6 C 1) in formula. 4 times is there because in 6^n there are 6 possibilities of getting all n times the same number. In 2^n * (6 C 2) there is 30 possibilities of getting the same number. So I have to add 24 possibilities of getting the same number. Right?

• Why is there no term corresponding to getting three numbers? Then you have to do careful inclusion/exclusion. – André Nicolas Oct 16 '15 at 0:16

As André said, the term for $3$ numbers is missing. To take it into account, you need to subtract $\binom633^n$; then rolls with only $2$ numbers, of which there are $\binom622^n$, have been subtracted $4$ times each, so you need to add them $3$ times, for a contribution of $45\cdot2^n$; and then rolls with only $1$ number, of which there are $\binom611^n$, have been subtracted $\binom52=10$ times and added $3\cdot5=15$ times, so you need to subtract them $6$ times, for a contribution of $36\cdot1^n$.
Alternatively, you can use Stirling numbers of the second kind to count the rolls that contain all $6$ numbers, $6!\left\{n\atop6\right\}=\sum_{j=1}^6(-1)^j\binom 6jj^n$, $5$ of the numbers, $6\cdot5!\left\{n\atop5\right\}=6\sum_{j=1}^5(-1)^{j+1}\binom 5jj^n$, or $4$ of the numbers, $\binom62\cdot4!\left\{n\atop4\right\}=15\sum_{j=1}^4(-1)^j\binom 4jj^n$, again for a total of
$$6^n-20\cdot3^n+45\cdot2^n-36\cdot1^n\;.$$
Alternatively, you can subtract from the total number $6^n$ of rolls the rolls that contain $3$ numbers, $\binom63\cdot3!\left\{n\atop3\right\}=20\sum_{j=1}^3(-1)^{j+1}\binom3jj^n$, $2$ numbers, $\binom62\cdot2!\left\{n\atop2\right\}=15\sum_{j=1}^2(-1)^j\binom2jj^n$, or $1$ number, $6\cdot1^n$, which again yields the same total as above.