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

Robert Kern robert.kern@gmail....
Thu Feb 12 13:18:26 CST 2009


On Thu, Feb 12, 2009 at 10:58, Michael S. Gilbert
<michael.s.gilbert@gmail.com> wrote:
> 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.

Why do you think that?

> 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?

The incompatibility is a showstopper to replacing the PRNG on any platform.

-- 
Robert Kern

"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 mailing list