Puzzled about random initialisation

Robin Becker robin at SPAMREMOVEjessikat.fsnet.co.uk
Thu Jul 8 21:05:51 CEST 2004


Paul Rubin wrote:
> Robin Becker <robin at reportlab.com> writes:
> 
>>I get dirrent draws for each run even when the system time doessn't
>>differ bu much. I'm puzzled exactly how the random generator is being
>>initialised.
> 
> 
> The rng has complicated internal state that's initialized completely
> different if the seeds are even slightly different.  If you want to
> study the algorithm, google on "mersenne twister".  The random module
> is not random enough for the most demanding applications, particularly
> those where someone who has studied the algorithm might be trying to
> predict the output, for example online games being played for large
> real prizes.  But it should be good enough for most stuff like
> physical simulations.

I'm not sure that answers my question. The seed in question is supposed 
to be determinate.

The docs say system time is used as an initial seed and my reading of 
the code seems to suggest that the actual input is a single time_t value 
which apparently changes once per second.

Observation suggests that we don't get the same value even when separate 
python processes start in the same system time second. So my 
understanding is flawed.

However, I would still like to know how random starting a python process 
and taking a single randint value is?  Can someone clever guess what 
values will be thrown up in a specified system time second?
-- 
Robin Becker



More information about the Python-list mailing list