[Python-Dev] Re: Mersenne Twister

Tim Peters tim.one@comcast.net
Thu, 29 Aug 2002 17:39:52 -0400

> -- Write, test and document the generator first.  Afterwards, explore
>     techniques for creating multiple independent streams:
>     http://www.math.h.kyoto-u.ac.jp/~matumoto/RAND/DC/dc.html

> Isn't that trivial if you follow the WH implementation strategy which
> stores all the state in a class instance?

"Independent" has more than one meaning.  The implementation meanings you
have in mind (two instances of the generator don't share state, and nothing
one does affects what the other does) are indeed trivially achieved via
attaching all state to an instance.

A different meaning of "independent" is "statistically uncorrelated", and
that's more what the link is aiming at.  It's never easy to get multiple,
statistically independent streams.  For example, using WH's jumpahead, it's
possible that you pick a large number N, jumpahead(N) in one instance of a
WH generator, and then the two streams turn out to be perfectly correlated.
That's trivially so if you pick N to be a multiple of WH's period, but there
are smaller values of N that also suffer.  One reason to run a simulation
multiple times with distinct generators is that it's pragmatically
impossible to outguess all this stuff.  Two generators are a sanity check;
three can break the impasse when the first two deliver significantly
different results; four is clearly excessive <wink>.