[Numpy-discussion] RandomArray question

Chad Netzer cnetzer at mail.arc.nasa.gov
Fri Mar 29 18:01:02 CST 2002

> <johanfo at ohman.no> writes:
>Take a look at the first number in each run !

That is because the random starting seed is (probably, I haven't looked 
at the code) set from the clock, and doesn't change all that much from 
run to run.

You'll see similar results when you substitute:

        print "Clock at time:" , i, ":", RandomArray.random_integers(10)


        print "Clock at time:" , i, ":", RandomArray.uniform(1, 10)

into your code.  The part before the decimal point is always the same 
on the first call of each run (assuming you run them at roughly the 
same time).

Note that the 'seed' is really the internal state of the RNG and 
changes at each call.  You could call the random function a few dozen 
times before using results, or hash the first result and use that as a 
new seed, etc.  But basically, the generator will produce similar 
initial results (ie. one call) for similar seeds, which is what the 
time value is causing.

I'd propose that the implementation, when setting the seed from the 
time, generate at least one dummy RNG generation before returning 


Chad Netzer
chad.netzer at stanfordalumni.org

More information about the Numpy-discussion mailing list