On Wed, Nov 10, 2010 at 11:33 AM, Lauri Alanko <l...@iki.fi> wrote: > So a naive implementation of split would be: > > split g = (mkGen seed, g') > where (seed, g') = random g
Just to be clear, that is the same as Burton Smith's original proposal that Simon mentioned at the outset, right? Specifically, Smith's proposal is yours instantiated with a crypto based PRNG? So, except for the silliness of generating 128 random bits to make an Int, the following would implement the strategy using the "crypto" package on Hackage, correct? -------------------------------------------------- import Codec.Encryption.AES import Data.LargeWord import System.Random data RNG = RNG Word128 Word128 deriving Show next128 (RNG k c) = (encrypt k c, RNG k (c+1)) instance RandomGen RNG where next g = (fromIntegral n, g') where (n,g') = next128 g split g@(RNG k c) = (g', RNG n 0) where (n,g') = next128 g -------------------------------------------------- The reason I brought up AES-NI was that doing AES in hardware would allow about an 8X improvement over the best software implementation (~2 cycles per byte encrypted). Comparison would be warranted, but perhaps it could make the crypto based PRNG efficient enough for day-to-day use. Best, -Ryan
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe