# What is the probability that at least $2$ out of $4$ digits in a code is the same?

If I choose $4$ digits for a code randomly out of the digits $0$ to $9$. What is the probability that at least $2$ of these digits are the same?

By at least I mean that you have to count with the probability that even $3$ or $4$ (all) digits are the same.

I tried to use the Hypergeometric distribution to calculate this problem but that's obviously wrong as it implies that you can not redraw a already picked digit.

How do I do this and is there any of these methods that I can use? Binomial, Hypergeometric approximated?

• What is the probability that no digits are the same? Commented Jan 5, 2016 at 10:09
• $1-\frac{\binom{10}{4}\cdot4!}{10^4}$ Commented Jan 5, 2016 at 10:15

Hint: There are $\binom{10}{4}$ ways to choose four distinct digits from $0$-$9$. For each choice of four digits, there are $4!$ ways to arrange those digits into a code. Now divide by the number of $4$ digit codes made from the digits $0$-$9$. This gives the complement of the probability you are looking for.
The easiest way is to calculate the probability of the inverse case where each digit is unique. When picking the first digit all ten digits are unused, nine are unused for the second, eight for the third and seven for the fourth and final. The probability of the inverse case where we have no duplicates is then just $\frac{10}{10} \times \frac{9}{10} \times \frac{8}{10} \times \frac{7}{10} = 0.504$.
To get the case where at least two digits are the same, subtract from one: $1 - 0.504 = 0.496$.