Copyright | Copyright (c) Patrick Perry <patperry@stanford.edu> |
---|---|
License | BSD3 |
Maintainer | Patrick Perry <patperry@stanford.edu> |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Random number generators.
- newtype RNG = MkRNG (ForeignPtr ())
- data RNGType
- newRNG :: RNGType -> IO RNG
- setSeed :: RNG -> Word64 -> IO ()
- getSample :: RNG -> IO Word64
- getUniform :: RNG -> IO Double
- getUniformPos :: RNG -> IO Double
- getUniformInt :: RNG -> Int -> IO Int
- getName :: RNG -> IO String
- getMax :: RNG -> IO Word64
- getMin :: RNG -> IO Word64
- getSize :: RNG -> IO Word64
- getState :: RNG -> IO [Word8]
- setState :: RNG -> [Word8] -> IO ()
- copyRNG :: RNG -> RNG -> IO ()
- cloneRNG :: RNG -> IO RNG
- mt19937 :: RNGType
- rngType :: String -> Maybe RNGType
Data types
Initializing
newRNG :: RNGType -> IO RNG Source #
Allocate a new random number generator of the given type and initialize it with the default seed.
Sampling
getUniformInt :: RNG -> Int -> IO Int Source #
Returns an integer uniform on [0,n-1]. n
must be greater than 0
.
Auxiliary functions
setState :: RNG -> [Word8] -> IO () Source #
Set the generator state. The input array should have size equal
to getSize
of the generator; otherwise, strange things will happen.
Copying state
copyRNG :: RNG -> RNG -> IO () Source #
copyRNG dst src
copies the state from one generator to another. The
two generators must have the same type.
cloneRNG :: RNG -> IO RNG Source #
Allocate a new random number generator that is an exact copy of another generator