Copyright | Copyright (c) 2009-2014, David Sorokin <david.sorokin@gmail.com> |
---|---|
License | BSD3 |
Maintainer | David Sorokin <david.sorokin@gmail.com> |
Stability | experimental |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Tested with: GHC 7.8.3
Below is defined a random number generator.
- class (Functor m, Monad m) => GeneratorMonad m where
- data Generator m :: *
- generateUniform :: Generator m -> Double -> Double -> m Double
- generateUniformInt :: Generator m -> Int -> Int -> m Int
- generateNormal :: Generator m -> Double -> Double -> m Double
- generateExponential :: Generator m -> Double -> m Double
- generateErlang :: Generator m -> Double -> Int -> m Double
- generatePoisson :: Generator m -> Double -> m Int
- generateBinomial :: Generator m -> Double -> Int -> m Int
- newGenerator :: Session m -> GeneratorType m -> m (Generator m)
- newRandomGenerator :: RandomGen g => Session m -> g -> m (Generator m)
- newRandomGenerator01 :: Session m -> m Double -> m (Generator m)
- data GeneratorType m
- = SimpleGenerator
- | SimpleGeneratorWithSeed Int
- | CustomGenerator (m (Generator m))
- | CustomGenerator01 (m Double)
Documentation
class (Functor m, Monad m) => GeneratorMonad m where Source
Defines a monad whithin which computation the random number generator can work.
generateUniform :: Generator m -> Double -> Double -> m Double Source
Generate an uniform random number with the specified minimum and maximum.
generateUniformInt :: Generator m -> Int -> Int -> m Int Source
Generate an uniform integer random number with the specified minimum and maximum.
generateNormal :: Generator m -> Double -> Double -> m Double Source
Generate a normal random number with the specified mean and deviation.
generateExponential :: Generator m -> Double -> m Double Source
Generate a random number distributed exponentially with the specified mean (the reciprocal of the rate).
generateErlang :: Generator m -> Double -> Int -> m Double Source
Generate the Erlang random number with the specified scale (the reciprocal of the rate) and integer shape.
generatePoisson :: Generator m -> Double -> m Int Source
Generate the Poisson random number with the specified mean.
generateBinomial :: Generator m -> Double -> Int -> m Int Source
Generate the binomial random number with the specified probability and number of trials.
newGenerator :: Session m -> GeneratorType m -> m (Generator m) Source
Create a new random number generator by the specified type with current session.
newRandomGenerator :: RandomGen g => Session m -> g -> m (Generator m) Source
Create a new random generator by the specified standard generator within current session.
newRandomGenerator01 :: Session m -> m Double -> m (Generator m) Source
Create a new random generator by the specified uniform generator of numbers from 0 to 1 within current session.
data GeneratorType m Source
Defines a type of the random number generator.
SimpleGenerator | The simple random number generator. |
SimpleGeneratorWithSeed Int | The simple random number generator with the specified seed. |
CustomGenerator (m (Generator m)) | The custom random number generator. |
CustomGenerator01 (m Double) | The custom random number generator by the specified uniform generator of numbers from 0 to 1. |