Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!uxc!uxc.cso.uiuc.edu!uxg.cso.uiuc.edu!uxe.cso.uiuc.edu!mcdonald From: mcdonald@uxe.cso.uiuc.edu Newsgroups: comp.lang.c Subject: Re: How do I get random #s? Message-ID: <225800132@uxe.cso.uiuc.edu> Date: 14 Feb 89 15:01:00 GMT References: <19415@dhw68k.cts.com> Lines: 33 Nf-ID: #R:dhw68k.cts.com:19415:uxe.cso.uiuc.edu:225800132:000:1512 Nf-From: uxe.cso.uiuc.edu!mcdonald Feb 14 09:01:00 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