[Haskell-cafe] Performance question

Bertram Felgenhauer bertram.felgenhauer at googlemail.com
Thu Feb 26 07:08:02 EST 2009

haskell at kudling.de wrote:
> Do you think it would be feasable to replace the GHC implementation
> of System.Random with something like System.Random.Mersenne?

There's a problem with using the Mersenne Twister: System.Random's
interface has a split method:

class RandomGen g where
   split    :: g -> (g, g)

The Mersenne Twister is good at producing a single stream of random
numbers - in fact it works by generating a whole block of random
numbers in one go, then consuming the block, and only then generating
the next block.

I have no idea how to implement a split method that produces
independent streams. Even if I did, using split a lot would likely
spoil the performance benefit of the generator.

(System.Random.Mersenne.Pure64 provides a RandomGen instance for
PureMT, but it cheats:)

   split = error "System.Random.Mersenne.Pure: unable to split the mersenne twister"


More information about the Haskell-Cafe mailing list