Mail Archives: djgpp/1998/04/28/06:34:50
Elias Pschernig wrote:
>
> hi, i dont understand everything of the article,
> but when reading it, it seems GNU's random
> number function is not very good ?
>
Sort of. It is probably good enough for 99% of all applications using
random numbers. In particular, if you are programming games, it is
certainly random enough.
> because i wrote a program to test the random
> numbers, and i just counted how often the
> first 32 bits (from 0 to 31) appear, and so far
> the random numbers do work, after a million
> times or so there still was no such difference
> in their count that i thought it wouldn't work.
>
The "spectral test" used by the original poster attempts to detect "low
order correlations". Its result shows that sets of three successive calls
to rand() tend to be correlated with each other. If you take three
successive random numbers and interpret them as the coordinates of a
point in 3d space, the result obtained on the spectral test says that
these points tend to fall along a small number of planes.
> so does the article say it's not good to use
> GNU's rand() function in programs any longer,
> or can i go on using it ?
The article says that, given the algorithm chosen, one could choose
better parameters than those use in rand(). In practice, it means that if
you are doing research in statistics and you need a random number
generator, or if you do Monte Carlo integration of a very "hairy"
function, DJGPP rand() *might* cause you problems, and you should cross
check your results with those obtained with another RNG (but this is a
sensible thing to do everytime you use random numbers in a serious
fashion). For all other cases, DJGPP's rand() is IMHO good enough, and
you can go on using it.
Francois
- Raw text -