| Copyright | (c) 2020 Naoyuki MORITA |
|---|---|
| License | BSD3 |
| Maintainer | naoyuki.morita@gmail.com |
| Stability | experimental |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
System.Random.MRG32k3a
Contents
Description
Pseudo-random number generation with MRG32k3a [1].
The generator type Gen is an instance of RandomGen type class, so
it can be used through RandomGen intreface functions such like,
> let g =initialize12345 > let (x, g') =uniformg :: (Word32, Gen) in x 3320887301
Notice: MRG32k3a is originally designed to generate random numbers following U(0,1). It DOES NOT generate exactly 32-bit information at a time.
If you need U(0,1) random numbers, use uniform01 that generates a
random value efficiently by original MRG32k3a algorithm.
Gen: Pseudo-Random Number Generators
The generator type.
Instances
| RandomGen Gen Source # | |
Defined in System.Random.MRG32k3a Methods genWord8 :: Gen -> (Word8, Gen) # genWord16 :: Gen -> (Word16, Gen) # genWord32 :: Gen -> (Word32, Gen) # genWord64 :: Gen -> (Word64, Gen) # genWord32R :: Word32 -> Gen -> (Word32, Gen) # genWord64R :: Word64 -> Gen -> (Word64, Gen) # genShortByteString :: Int -> Gen -> (ShortByteString, Gen) # | |
initialize :: Word32 -> Gen Source #
Create a generator using given seed.
Unitility functions
Seed: state management
An immutable snapshot of the state of a Gen.
fromSeed :: Seed -> (Word32, Word32, Word32, Word32, Word32, Word32) Source #
Convert seed into a 6-tuple of Word32.
Stream jumping
jump :: Int -> Gen -> Gen Source #
Get a new generator jumps ahead by \(2^n\) steps from given generator.
> let g0 =initialize12345 > let g1 =jump20 g0 > let xs = unfoldr (Just .uniform01) g0 > let ys = unfoldr (Just .uniform01) g1 > take 10 $ drop 1048576 xs [0.42963674510001276,0.10482156807623948,0.9889648413995019,0.785875227875553,0.9522150221887802,0.9792979233185687,0.8713777766671446,0.9231321178403405,0.13047652927672448,0.5395971153015737] > take 10 $ ys [0.42963674510001276,0.10482156807623948,0.9889648413995019,0.785875227875553,0.9522150221887802,0.9792979233185687,0.8713777766671446,0.9231321178403405,0.13047652927672448,0.5395971153015737]
References
[1] Pierre L'Ecuyer, (1999) Good Parameters and Implementations for Combined Multiple Recursive Random Number Generators.Operations Research 47(1):159-164. https://doi.org/10.1287/opre.47.1.159