[Numpy-discussion] Purpose for bit-wise and'ing the initial mersenne twister key?

Michael S. Gilbert michael.s.gilbert@gmail....
Thu Feb 12 10:58:00 CST 2009

On Fri, 6 Feb 2009 18:18:44 -0500 "Michael S. Gilbert" wrote:
> BTW, there is a 64-bit version of the reference mersenne twister 
> implementation available [1].

I did some testing with this 64-bit implementation (mt19937-64). I've
found that it is actually slower than the 32-bit reference (mt19937ar)
on 64-bit systems (2.15s vs 2.25s to generate 100000000 ints). This is
likely because it generates 64-bit long long ints instead of 32-bit
long ints. However, it should be possible to break up each 64-bit int
into two 32-bit ints, then the runtime would appear to be almost twice
as fast. One other consideration to keep in mind is that the 64-bit
version is not stream-compatible with the 32-bit implementation (you
will get different sequences for the same input seed).

Would it be worth it to implement this in numpy in order to get an
almost 2x speedup on 64-bit machines?

More information about the Numpy-discussion mailing list