[Haskell-cafe] Announce: mersenne-random 0.1, very fast pseudo-random number generation for Haskell

Don Stewart dons at galois.com
Mon Jan 21 22:53:13 EST 2008

Hey all,

I'm pleased to announce the creation of the mersenne-random package,
The Mersenne twister is a pseudorandom number generator developed by
Makoto Matsumoto and Takuji Nishimura, that provides for fast generation
of very high quality pseudorandom numbers, suitable for simulators and monte carlo

This library binds to 'SFMT', the SIMD-oriented Fast Mersenne Twister. SFMT is
a variant of Mersenne Twister that is much faster than the original. It is
designed to be fast when it runs on 128-bit SIMD.

To compile in the vector instructions use Cabal, and pass '-f use_sse2'
 or '-f use_altivec' to configure, depend on which set your cpu supports (or
none if it doesn't). The use of sse2 instructions will typically halve
the generation time.

The library is very fast (generation of Ints and Doubles will be some 50x
faster than System.Random), but the implementation we bind to is heavily
impure, so only a single generator is possible per-process (splitting
generators is also not supported).

Some light abstractions are implemented over the raw C interface, including
a type class for SFMT-generated Haskell values, and lists of those values.

Full 64 bit Ints and Doubles, and 53-bit precision Doubles, are supported on 64
bit machines.

As usual, the stable branch is on hackage, so you can install it with

    $ cabal install mersenne-random

Note that the cpu isn't detected automatically, so to turn on SIMD flags
for your cpu, you'll need to build it by hand from:


And the darcs repo is at code.haskell.org,

    darcs get http://code.haskell.org/~dons/code/mersenne-random

A test suite and example programs are provided.


More information about the Haskell-Cafe mailing list