What are the odds based on time?

38 Views Asked by At

I need to know the odds in order to determine if this method of generating a random number will be effective.

The variables:

A counter based on milliseconds to the 7th digit.
    This is a counter that iterates every millisecond. (0-9999999)
This counter will reset when it reaches 9999999.

Every year 30,000 numbers will be pulled from this set of numbers.

What are the chances one of these numbers will repeat?

1

There are 1 best solutions below

0
On BEST ANSWER

This is essentially the Birthday Problem, on a planet where the year has $10^8$ days and we have 30,000 people in the room. We want to know the probability that at least two people will have the same birthday. See https://en.wikipedia.org/wiki/Birthday_problem

The exact solution would be a computational nightmare due to the size of the numbers involved, but we can employ what the Wikipedia page calls the Poisson approximation. There are $\binom{30,000}{2}$ pairs of people, and for any pair, the probability that the two people have the same birthday is $10^{-8}$. So the expected number of matches is $$\lambda = \binom{30,000}{2} \cdot 10^{-8} \approx 4.50$$ It seems reasonable to assume that the number of matches, say $X$, is approximately distributed as a Poisson random variable with parameter $\lambda$; so the probability that there is at least one match is approximately $$\Pr(X > 0) = 1-e^{-\lambda} \approx 0.9889$$