random-fu-0.1.4: Random number generation

Data.Random.Distribution.Normal

Synopsis

Documentation

data Normal a Source

A specification of a normal distribution over the type a.

Constructors

StdNormal

The "standard" normal distribution - mean 0, stddev 1

Normal a a

Normal m s is a normal distribution with mean m and stddev sd.

normal :: Distribution Normal a => a -> a -> RVar aSource

normal m s is a random variable with distribution Normal m s.

normalT :: Distribution Normal a => a -> a -> RVarT m aSource

normalT m s is a random process with distribution Normal m s.

stdNormal :: Distribution Normal a => RVar aSource

stdNormal is a normal variable with distribution StdNormal.

stdNormalT :: Distribution Normal a => RVarT m aSource

stdNormalT is a normal process with distribution StdNormal.

doubleStdNormal :: RVarT m DoubleSource

A random variable sampling from the standard normal distribution over the Double type.

floatStdNormal :: RVarT m FloatSource

A random variable sampling from the standard normal distribution over the Float type.

realFloatStdNormal :: (RealFloat a, Erf a, Distribution Uniform a) => RVarT m aSource

A random variable sampling from the standard normal distribution over any RealFloat type (subject to the rest of the constraints - it builds and uses a Ziggurat internally, which requires the Erf class).

Because it computes a Ziggurat, it is very expensive to use for just one evaluation, or even for multiple evaluations if not used and reused monomorphically (to enable the ziggurat table to be let-floated out). If you don't know whether your use case fits this description then you're probably better off using a different algorithm, such as boxMullerNormalPair or knuthPolarNormalPair. And of course if you don't need the full generality of this definition then you're much better off using doubleStdNormal or floatStdNormal.

As far as I know, this should be safe to use in any monomorphic Distribution Normal instance declaration.

normalTail :: (Distribution StdUniform a, Floating a, Ord a) => a -> RVarT m aSource

Draw from the tail of a normal distribution (the region beyond the provided value)

normalPair :: (Floating a, Distribution StdUniform a) => RVar (a, a)Source

A random variable that produces a pair of independent normally-distributed values.

boxMullerNormalPair :: (Floating a, Distribution StdUniform a) => RVar (a, a)Source

A random variable that produces a pair of independent normally-distributed values, computed using the Box-Muller method. This algorithm is slightly slower than Knuth's method but using a constant amount of entropy (Knuth's method is a rejection method). It is also slightly more general (Knuth's method require an Ord instance).

knuthPolarNormalPair :: (Floating a, Ord a, Distribution Uniform a) => RVar (a, a)Source

A random variable that produces a pair of independent normally-distributed values, computed using Knuth's polar method. Slightly faster than boxMullerNormalPair when it accepts on the first try, but does not always do so.