[Haskell-cafe] a random numbers generator with a good 'split'

deb at pudlak.name deb at pudlak.name
Sun Aug 8 03:43:02 EDT 2010

    Hi cafe.

recently I was looking at various possibilities of generating random
numbers in Haskell. Apparently, the main problem is the 'split' function
in the System.Random.RandomGen class. Since it is rarely needed in
imperative programs, not much is known how to implement it safely. It's
documentation says:

> The split operation allows one to obtain two distinct random number
> generators. This is very useful in functional programs (for example,
> when passing a random number generator down to recursive calls), but
> very little work has been done on statistically robust implementations
> of split ([System.Random, System.Random] are the only examples we know
> of). 

I consulted it with a friend, who has done much work in the area of
random number generators. He suggested that this might be implemented
using a random number generator with a very large period, such as
Mersene Twister (MT19937 has a period of 2^19937-1). A pair of splitted
generators states could be positioned sufficiently far enough from each
other so that in practice they never reach each other, and in such a way
that successive splits (in practice) never meet.

I searched Hackage, where I found a few implementations of Mersene
Twister, but AFAIK no one actually implements neither RandomGen nor
'split' alone. I wonder why -- is RandomGen inconvenient or obsolete in
some way? Or just nobody tried?

  With best regards,
  Petr Pudlak

PS: Sorry if you get multiple copies, I had problems sending the mail.

More information about the Haskell-Cafe mailing list