Copyright | (c) Sam Stites 2017 |
---|---|
License | BSD3 |
Maintainer | sam@stites.io |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Random number generation for single values. FFI over TH/THRandom.h
Synopsis
- data Generator
- data Seed
- newRNG :: IO Generator
- copy :: Generator -> Generator -> IO Generator
- seed :: Generator -> IO Seed
- manualSeed :: Generator -> Seed -> IO ()
- initialSeed :: Generator -> IO Seed
- random :: Generator -> IO Seed
- random64 :: Generator -> IO Seed
- uniform :: Generator -> Double -> Double -> IO Double
- uniformFloat :: Generator -> Float -> Float -> IO Float
- normal :: Generator -> Double -> Double -> IO Double
- exponential :: Generator -> Double -> IO Double
- standard_gamma :: Generator -> Double -> IO Double
- cauchy :: Generator -> Double -> Double -> IO Double
- logNormal :: Generator -> Double -> Double -> IO Double
- geometric :: Generator -> Double -> IO Int
- bernoulli :: Generator -> Double -> IO Int
Documentation
Representation of a CPU-bound random number generator
Representation of a CPU-bound random seed
Returns a random double according to uniform distribution on [a,b).
Returns a random float according to uniform distribution on [a,b).
Returns a random real number according to a normal distribution with the given mean and standard deviation stdv. stdv must be positive, but this is not yet enforced.
TODO: add a newtype Pos a = Pos { getPos :: a }
package with a smart constructor export
exponential :: Generator -> Double -> IO Double Source #
Returns a random real number according to the exponential distribution p(x) = lambda * exp(-lambda * x)
Returns a random real number according to the Cauchy distribution p(x) = sigma/(pi*(sigma^2 + (x-median)^2))
Returns a random real number according to the log-normal distribution, with the given mean and standard deviation stdv. mean and stdv are the corresponding mean and standard deviation of the underlying normal distribution, and not of the returned distribution.
stdv must be positive.