[Haskell-cafe] Performance question

Lennart Augustsson lennart at augustsson.net
Thu Feb 26 07:17:00 EST 2009


You can implement a reasonable split if you can fast-forward the generator.
There's no known method to fast-forward the MT, but other generators
like MRG32k3a can handle it.

  -- Lennart

On Thu, Feb 26, 2009 at 12:08 PM, Bertram Felgenhauer
<bertram.felgenhauer at googlemail.com> wrote:
> 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"
>
> Bertram
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>


More information about the Haskell-Cafe mailing list