How do I get random #s?

mcdonald at uxe.cso.uiuc.edu mcdonald at uxe.cso.uiuc.edu
Wed Feb 15 01:01:00 AEST 1989


>
>If you program in SIMSCRIPT or SIMULA or any other simulation language
>(except GPSS) you will get a fine random number generator at your
>disposal. C was evidently designed by people who didn't need random
>numbers - the standardized rand() doesn't allow a seed to be
>specified, making it useless when you need independent streams of
>random numbers.

>BTW, you don't need to do a lot of work - just look up a few
>references. Any reasonably theoretical book on simulation should go
>into generation of random deviates, spectral measures of randomness,
>etc. You can usually skip most of that and copy an algorithm from
>Knuth, anyway.


Depends on how important it is that your numbers are really random.
If it matters, I suggest that YOU figure out what property of randomness
matters most to you, and test it on a possible generator candidate.

Let me tell a little story: A friend, who worked for the leading 
professor in the field, was doing classical dynamical trajectories
on molecules. The initial conditions come in ordered triples,
i.e. x, y, and z or px, py, pz. It seems that the standard IBM
360 Fortran random generator generated triples, all of which 
lay in eight planes in three-space. And - one of these planes
passed through a near-singularity in the results. Result:
final results which weren't right - by a lot. Luckily this guy 
was smart enough to figure out from the answer what was happening.

The properties listed in books may NOT be the ones that matter to YOU.

Doug McDonald



More information about the Comp.lang.c mailing list