State of the random number generator
Modulepcg-random-0.1.4.0Haskell2010
System.Random.PCG.Pure
Standard PCG Random Number Generator with chosen streams, written in pure haskell. See http://www.pcg-random.org for details.
import Control.Monad.ST
import System.Random.PCG.Pure
three :: [Double]
three = runST $ do
g <- create
a <- uniform g
b <- uniform g
c <- uniform g
return [a,b,c]
- 5 types
- 1 class
- 45 values
- Packagepcg-random-0.1.4.0
- Exports51
- LanguageHaskell2010
- LicenceBSD-3-Clause
- SourcePure.hs
Gen
7 declarationsCreate a Gen from a fixed initial seed.
Seed with system random number. (/dev/urandom on Unix-like
systems and CryptAPI on Windows).
Initialize a generator a single word.
Pure.initialize 0 0 >>= Pure.saveSetSeq 6364136223846793006 1
Seed with system random number. (/dev/urandom on Unix-like
systems and CryptAPI on Windows).
Getting random numbers
3 declarationsMethods
uniform :: Generator g m => g -> m aGenerate a uniformly distributed random vairate.
Use entire range for integral types.
Use (0,1] range for floating types.
uniformR :: Generator g m => (a, a) -> g -> m aGenerate a uniformly distributed random vairate in the given range.
Use inclusive range for integral types.
Use (a,b] range for floating types.
uniformB :: Generator g m => a -> g -> m aGenerate a uniformly distributed random vairate in the range [0,b). For integral types the bound must be less than the max bound of Word32 (4294967295). Behaviour is undefined for negative bounds.
Instances16Variate, …
Variate Int16Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Int32Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Int64Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Int8Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Word16Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Word32Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Word64Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate Word8Defined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate BoolDefined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate DoubleDefined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate FloatDefined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate IntDefined in pcg-random-0.1.4.0 · System.Random.PCG.ClassVariate WordDefined in pcg-random-0.1.4.0 · System.Random.PCG.Class(Variate a, Variate b) => Variate (a, b)Defined in pcg-random-0.1.4.0 · System.Random.PCG.Class(Variate a, Variate b, Variate c) => Variate (a, b, c)Defined in pcg-random-0.1.4.0 · System.Random.PCG.Class(Variate a, Variate b, Variate c, Variate d) => Variate (a, b, c, d)Defined in pcg-random-0.1.4.0 · System.Random.PCG.Class
Advance the given generator n steps in log(n) time. (Note that a "step" is a single random 32-bit (or less) Variate. Data types such as Double or Word64 require two "steps".)
Pure.create >>= \g -> replicateM_ 1000 (uniformW32 g) >> uniformW32 g3640764222Pure.create >>= \g -> replicateM_ 500 (uniformD g) >> uniformW32 g3640764222Pure.create >>= \g -> Pure.advance 1000 g >> uniformW32 g3640764222
Retract the given generator n steps in log(2^64-n) time. This
is just advance (-n).
Pure.create >>= \g -> replicateM 3 (uniformW32 g)[355248013,41705475,3406281715]Pure.create >>= \g -> Pure.retract 1 g >> replicateM 3 (uniformW32 g)[19683962,355248013,41705475]
Seeds
5 declarationsSave the state of a Gen in a Seed.
Restore a Gen from a Seed.
Fixed seed.
Create a new generator from two words.
Pure.initFrozen 0 0SetSeq 6364136223846793006 1
Type restricted versions
0 declarationsuniform
uniformR
uniformB
Pure
3 declarationsThe multiple sequence varient of the pcg random number generator.
Instances8Eq, Data, Ord, Show, Generic, Storable, …
Eq SetSeqDefined in pcg-random-0.1.4.0 · System.Random.PCG.PureData SetSeqDefined in pcg-random-0.1.4.0 · System.Random.PCG.PureOrd SetSeqDefined in pcg-random-0.1.4.0 · System.Random.PCG.PureShow SetSeqDefined in pcg-random-0.1.4.0 · System.Random.PCG.PureGeneric SetSeqDefined in pcg-random-0.1.4.0 · System.Random.PCG.PureStorable SetSeqDefined in pcg-random-0.1.4.0 · System.Random.PCG.PureRandomGen FrozenGenDefined in pcg-random-0.1.4.0 · System.Random.PCG.Puretype Rep SetSeq = D1 ('MetaDataDefined in pcg-random-0.1.4.0 · System.Random.PCG.Pure"SetSeq"
"System.Random.PCG.Pure"
"pcg-random-0.1.4.0-Bhb5XGfIMVVHgPMpu7qblw"
'False) (C1 ('MetaCons"SetSeq"
'PrefixI 'False) (S1 ('MetaSel 'Nothing 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 Word64) :*: S1 ('MetaSel 'Nothing 'SourceUnpack 'SourceStrict 'DecidedUnpack) (Rec0 Word64)))
Pure version of advance.