monte-carlo-0.4.2: A monad and transformer for Monte Carlo calculations.

MaintainerPatrick Perry <>
Safe HaskellNone




A monad and monad transformer for monte carlo computations built on top of the functions in the GNU Scientific Library.


The Monte Carlo monad

data MC a Source

A Monte Carlo monad with an internal random number generator.


runMC :: MC a -> RNG -> (a, RNG)Source

Run this Monte Carlo monad with the given initial random number generator, getting the result and the new random number generator.

evalMC :: MC a -> RNG -> aSource

Evaluate this Monte Carlo monad and throw away the final random number generator. Very much like fst composed with runMC.

execMC :: MC a -> RNG -> RNGSource

Exicute this Monte Carlo monad and return the final random number generator. Very much like snd composed with runMC.

The Monte Carlo monad transformer

data MCT m a Source

A parameterizable Monte Carlo monad for encapsulating an inner monad.


MonadTrans MCT 
(Monad (MCT m), MonadError e m) => MonadError e (MCT m) 
(Monad (MCT m), MonadReader r m) => MonadReader r (MCT m) 
(Monad (MCT m), MonadState s m) => MonadState s (MCT m) 
(Monoid w, Monad (MCT m), MonadWriter w m) => MonadWriter w (MCT m) 
Monad m => Monad (MCT m) 
Monad m => Functor (MCT m) 
(Monad (MCT m), MonadPlus m) => MonadPlus (MCT m) 
(Functor (MCT m), Monad m) => Applicative (MCT m) 
(Monad (MCT m), MonadIO m) => MonadIO (MCT m) 
(Monad (MCT m), MonadCont m) => MonadCont (MCT m) 
(Monad (MCT m), HasRNG (* -> *) (MCT m), Monad m) => MonadMC (MCT m) 
Monad m => HasRNG (* -> *) (MCT m) 

runMCT :: Monad m => MCT m a -> RNG -> m (a, RNG)Source

Similar to runMC.

evalMCT :: Monad m => MCT m a -> RNG -> m aSource

Similar to evalMC.

execMCT :: Monad m => MCT m a -> RNG -> m RNGSource

Similar to execMC.

Pure random number generator creation

data RNG Source

The random number generator type associated with MC and MCT.

type Seed = Word64Source

The seed type for the random number generators.

mt19937 :: Seed -> RNGSource

Get a Mersenne Twister random number generator seeded with the given value.

mt19937WithState :: [Word8] -> RNGSource

Get a Mersenne Twister seeded with the given state.

rngName :: RNG -> StringSource

Get the name of the random number generator algorithm.

rngSize :: RNG -> IntSource

Get the size of the generator state, in bytes.

rngState :: RNG -> [Word8]Source

Get the state of the generator.

Overloaded Monte Carlo monad interface