- data Normal a
- normal :: Distribution Normal a => a -> a -> RVar a
- stdNormal :: Distribution Normal a => RVar a
- doubleStdNormal :: RVar Double
- floatStdNormal :: RVar Float
- realFloatStdNormal :: (RealFloat a, Erf a, Distribution Uniform a) => RVar a
- normalTail :: (Distribution StdUniform a, Floating a, Ord a) => a -> RVar a
- normalPair :: (Floating a, Distribution StdUniform a) => RVar (a, a)
- boxMullerNormalPair :: (Floating a, Distribution StdUniform a) => RVar (a, a)
- knuthPolarNormalPair :: (Floating a, Ord a, Distribution Uniform a) => RVar (a, a)
Documentation
A specification of a normal distribution over the type a
.
StdNormal | The "standard" normal distribution - mean 0, stddev 1 |
Normal a a |
|
(Real a, Distribution Normal a) => CDF Normal a | |
Distribution Normal Double | |
Distribution Normal Float |
normal :: Distribution Normal a => a -> a -> RVar aSource
normal m s
is a random variable with distribution
.
Normal
m s
stdNormal :: Distribution Normal a => RVar aSource
doubleStdNormal :: RVar DoubleSource
A random variable sampling from the standard normal distribution
over the Double
type.
floatStdNormal :: RVar FloatSource
A random variable sampling from the standard normal distribution
over the Float
type.
realFloatStdNormal :: (RealFloat a, Erf a, Distribution Uniform a) => RVar 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 -> RVar 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.