Calculate probability of choosing from pool with replacement and at least 2 are the same

probabilityrandom

From a group of 1000 numbers with replacement (1 … 1000), 40 numbers are chosen evenly,
How can I find the probability that 2 (at least) chosen numbers are equal?

I thought the following: for the first number if I compare it with any other, the probability that they are equal is 1/1000, right? (The first number is given, so in the group there is only one equal number), so I thought that comparing 2 would be 1/1000 that they are equal and then I did the comparison between all the possible pairs of my 40 numbers, that would be 780 comparisons and if each has a 1/1000 chance of being the same numbers, the total probability would be 780/1000 = 78%.

But i know im wrong somewhere, I'm doing a simulation with Python (code) and it gave me around 54.5% success.

Best Answer

It's often easier to calculate the complement event and then do 1- that. Here the complement event is that no two numbers are equal.

The first number is arbitrary, so there is no chance of it being duplicated, or 1000/1000

The second number has 999/1000 chance of being different from the first number

Continuing onwards, we get $$\frac {1000P40} {1000^{40}}$$ ways of picking 4 numbers

Doing the compliment, $$1-\frac {1000P40} {1000^{40}}$$ gets us via wolframalpha to roughly $54.64\%$, which meshes well with your experimental data