G
glen herrmannsfeldt
(snip)
Did anyone here ever figure out how many random numbers you need
to look at before the difference is statistically significant?
For one, if you have N random numbers between 0 and N-1, what
is the probability that all N are generated? (Assume that the
generator is actually random.)
If you flip a coin N times, what is the probability of getting N/2
heads. (Note that it is zero for all odd N.)
-- glen
The comp.lang.c FAQ is at http://www.c-faq.com/. You've just asked
question 13.16.
As others have pointed out, you can't generate uniformly distributed
numbers in the range 0..N-1 using a single call to rand() if RAND_MAX+1
is not a multiple of N. Some numbers will occur more often than others.
You can play tricks to change *which* numbers occur more often, but
you can't avoid the problem.
Did anyone here ever figure out how many random numbers you need
to look at before the difference is statistically significant?
For one, if you have N random numbers between 0 and N-1, what
is the probability that all N are generated? (Assume that the
generator is actually random.)
If you flip a coin N times, what is the probability of getting N/2
heads. (Note that it is zero for all odd N.)
-- glen