If we have had n random number generations between 1 and 100, what is the probability of the same number coming up twice?
If we have had n random number generations between 1 and 100, where n is a number less than 100, what is the probability of the same number coming up twice?
After 2 generations, I'm guessing there is a 1% chance of the same number coming up twice.
For any specific number there is a 1 in 100 chance of it coming up on the first 'roll'. On the second roll, again, 1 in 100 chance. So a 1 in 10 000 chance that a specific number will come up twice on those two rolls, or a 0.01% chance. So for the 100 possible numbers, there is a 100 * 1/10 000 chance of the same number coming up twice. That is 1/100 or 1%.
After 101 rolls, at least one number will come up twice. So when n=101 then the probability is 100%..
So, after 3 rolls, is there a 2% chance that at least two of the numbers generated are the same? That does not seem right. There are 100^n possible outcomes on n rolls, but how many of those outcomes have at least one number coming up twice?
I saw elsewhere that it is better sometimes to consider the probability of a result not happening. So when n=2 there is a 99/100 chance that the two numbers are different. That is, in 9900 of the 10 000 possible outcomes the two numbers are different. When n = 3 there are 1 000 000 possible outcomes, 100 * 100 * 100. But I do not know how to calculate the number of outcomes in which at least one number does not repeat.
Also, if we choose a specific number, what is the chance that it will be generated at least twice after n generations? When n = 2 there is a 0.01% (1/100 * 1/100) chance that, for example, the number 42 will be generated twice. Every extra roll will increase the chance, but by how much? In this case, even after 100 rolls, 42 may not even come up once, let alone twice.
$\endgroup$ 31 Answer
$\begingroup$The easiest way is to calculate the probability of all numbers being different.
The principle is that the first number can be any of the 100 numbers.
The second number can be any of the 100 numbers except the number taken in the first attempt, i.e. 99 numbers.
The third number can be any of the 100 numbers except the number taken in the first and second attempt, i.e. 98 numbers.
And so on.
n=1: P(all different) = 100/100
n=2: P(all different) = 100/100 * 99/100
n=3: P(all different) = 100/100 * 99/100 * 98/100
...
n=m: P(all different) = 100/100 * 99/100 * 98/100 * .... * (100-m+1)/100Then you have the probability of at least one number being present at least twice as 1-P(all different)
p(at least one number more than once) = 1 - P(all different) $\endgroup$