gsl-random-0.4: Bindings the the GSL random number generation facilities.

Stabilityexperimental
MaintainerPatrick Perry <patperry@stanford.edu>

GSL.Random.Gen

Contents

Description

Random number generators.

Synopsis

Data types

newtype RNG Source

Constructors

MkRNG (ForeignPtr ()) 

Initializing

newRNG :: RNGType -> IO RNGSource

Allocate a new random number generator of the given type and initialize it with the default seed.

setSeed :: RNG -> Word64 -> IO ()Source

Seed the generator with the given value.

Sampling

getSample :: RNG -> IO Word64Source

Returns a value uniform in [rngMin, rngMax]

getUniform :: RNG -> IO DoubleSource

Returns a value uniform on [0,1)

getUniformPos :: RNG -> IO DoubleSource

Returns a value uniform on (0,1)

getUniformInt :: RNG -> Int -> IO IntSource

Returns an integer uniform on [0,n-1]. n must be greater than 0.

Auxiliary functions

getName :: RNG -> IO StringSource

Get the name of the generator.

getMax :: RNG -> IO Word64Source

Get the largest value that the generator can return.

getMin :: RNG -> IO Word64Source

Get the smallest value that the generator can return.

getSize :: RNG -> IO Word64Source

Get the size of the generator state, in bytes.

getState :: RNG -> IO [Word8]Source

Get the generator state.

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 RNGSource

Allocate a new random number generator that is an exact copy of another generator

Algorithms