Probability of two identical faces when three dice are thrown I tried to make a web page that mimics throwing $3$ dice. I often get $2$ or all $3$ having the same number. Trying to figure out if the random generator is broken or its normal?
So if I throw similar $3$ dice randomly, how often will two of them have the same number?
I want to test my code, what will be a good sample size? $10,000$ trials? Each is $1$-$6$. Samples of code here: http://sel2in.com/pages/prog/html/dice
 A: Probability of getting $3$ same outcome is $\frac{6}{6^3}=\frac{6}{216}=\frac1{36}$.
Probability of getting all different outcome is $\frac{6}{6}\frac{5}{6}\frac{4}{6}=\frac{20}{36}$.
Probability of getting a pair of same outcome would be $1-$ the two quantity above. 
$$1-\frac{1}{36}-\frac{20}{36}=\frac{15}{36}$$
A: It may be helpful to note that the event of interest can be modeled using a discrete random variable $X$: $X = i$ if $i$ of three dices result in the same number, $i = 0, 2, 3$. You are interested in determining $P[X = 2]$ (or perhaps $P[X = 2] + P[X = 3]$).
Taking $P[X = 2]$ for example, it can be computed as follows:
\begin{align}
P[X = 2] = \frac{\binom{3}{2}\times\binom{6}{1}\times\binom{5}{1}}{6^3} = \frac{15}{36}.
\end{align}
The logic goes like this: imagine you are allocating three distinguishable balls into $6$ boxes labeled from $1$ to $6$. Without restriction, there are $6^3$ ways to do so. If it is required that exactly $2$ of three balls are allocated in the same box (hence the remaining ball must be put in another box), you can first determine which two balls will be allocated to the same box ($\binom{3}{2}$ ways), then you are free to choose which one they go ($\binom{6}{1}$ ways), finally, the third ball can go to any one of the remaining $5$ boxes.
In this way, you may enumerate the whole distribution of $X$. 
