Proposal: Move 'split' into a separate class in System.Random

Simon Peyton-Jones simonpj at microsoft.com
Wed Sep 15 02:46:03 EDT 2010


| > (Oh now I see Ivan mentions existing PRNGs that don't (can't?) support
| > split... that may be a reasonable argument; I'll have to think about it; is
| > this the main motivation? or just one observation among many?)
| 	
| I think it's the main one; that things like the Mersenne twister can't be
| made instances of Random has stuck in people's craws for a while.

In GHC's unique-supply generator we use a trick due to Lennart Augustsson to turn a linear generator (such as the Mersenne twister) into a splittable one.

Code is here: http://darcs.haskell.org/ghc/compiler/basicTypes/UniqSupply.lhs

Maybe the same would work for Mersenne. 

(Yes it uses unsafeInterleaveIO under the hood.)

Simon

| -----Original Message-----
| From: libraries-bounces at haskell.org [mailto:libraries-bounces at haskell.org] On
| Behalf Of Brandon S Allbery KF8NH
| Sent: 15 September 2010 05:01
| To: libraries at haskell.org
| Subject: Re: Proposal: Move 'split' into a separate class in System.Random
| 
| -----BEGIN PGP SIGNED MESSAGE-----
| Hash: SHA1
| 
| On 9/14/10 23:44 , Isaac Dupree wrote:
| > (Oh now I see Ivan mentions existing PRNGs that don't (can't?) support
| > split... that may be a reasonable argument; I'll have to think about it; is
| > this the main motivation? or just one observation among many?)
| 	
| I think it's the main one; that things like the Mersenne twister can't be
| made instances of Random has stuck in people's craws for a while.
| 
| - --
| brandon s. allbery     [linux,solaris,freebsd,perl]      allbery at kf8nh.com
| system administrator  [openafs,heimdal,too many hats]  allbery at ece.cmu.edu
| electrical and computer engineering, carnegie mellon university      KF8NH
| -----BEGIN PGP SIGNATURE-----
| Version: GnuPG v2.0.10 (Darwin)
| Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
| 
| iEYEARECAAYFAkyQRPkACgkQIn7hlCsL25WuNQCdE+XCzyytOfzO/2SAU/qk+jpj
| cx8Anjz9nToSZJNflAaIL3zJiI14iGc8
| =nx2g
| -----END PGP SIGNATURE-----
| _______________________________________________
| Libraries mailing list
| Libraries at haskell.org
| http://www.haskell.org/mailman/listinfo/libraries



More information about the Libraries mailing list