Copyright | (c) 2020 Naoyuki MORITA |
---|---|
License | BSD3 |
Maintainer | naoyuki.morita@gmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe |
Language | Haskell2010 |
Gen: Pseudo-Random Number Generators
The generator type.
Instances
RandomGen Gen Source # | |
Defined in System.Random.MRG63k3a 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 :: Int64 -> Gen Source #
Create a generator using given seed.
Unitility functions
Seed: state management
An immutable snapshot of the state of a Gen
.
fromSeed :: Seed -> (Word64, Word64, Word64, Word64, Word64, Word64) Source #
Convert seed into a 6-tuple of Word64
.
Stream jumping
jump :: Int -> Gen -> Gen Source #
Get a new generator jumps ahead by \(2^n\) steps from given generator.
> let g0 =initialize
1234567 > let g1 =jump
20 g0 > let xs = unfoldr (Just .uniform01
) g0 > let ys = unfoldr (Just .uniform01
) g1 > take 10 $ drop 1048576 xs [0.8661862534637614,0.32299545841103733,0.7545203812431158,0.6829503373808978,0.7938803872652808,0.3453801891716969,0.199924353479426,0.7548724584148777,0.4533723232806143,0.855651888940174] > take 10 ys [0.8661862534637614,0.32299545841103733,0.7545203812431158,0.6829503373808978,0.7938803872652808,0.3453801891716969,0.199924353479426,0.7548724584148777,0.4533723232806143,0.855651888940174]
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