[Numpy-discussion] random permutation
robert.kern at gmail.com
Sun Jan 14 00:22:36 EST 2007
Charles R Harris wrote:
> On 1/13/07, *Sebastian Haase* <seb.haase at gmx.net
> <mailto:seb.haase at gmx.net>> wrote:
> I understand this - but I thought the algorithm might involve some
> rounding(-error) cases that would produce different results especially
> when changing the CPU (intel vs. PowerPC). I found this to be true
> even for non pseudo-random code that between CPU-types results were
> different within a given epsilon.
> Its all 32 bit words, or rather bits. IIRC, it is based on an
> irreducible polynomial over Z_2, so all the coefficients are 0 or 1. The
> original paper is worth a read if you like that sort of stuff.
Well, there are a couple of issues, here. One is the core Mersenne Twister PRNG.
You are right that it should reliably produce the same bitstream on all
supported platforms. In fact, for the same state vector (*not* the seed), it
should produce the same results as the standard library's random.Random()
Now, the various distributions are another matter. They do rely on floating
point calculations, and I doubt that we can rely on them producing the exact
same streams of output on different processors, particularly those that use
Unfortunately, running distribution tests on all of the non-uniform
distributions requires implementations of lots of special functions. I did run
such tests using scipy.stats when I implemented the distributions, but I can't
really turn those into unit tests for numpy.
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the NumPy-Discussion