HORIZON HASKELLDocslts/ghc-9.10.x248f8f02026-10-05Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · 248f8f0 · 2026-10-05

Modulerandom-fu-0.3.0.1Haskell2010

Data.Random.Distribution.Normal

  • 1 type
  • 11 values
  • Packagerandom-fu-0.3.0.1
  • Exports12
  • LanguageHaskell2010
  • LicenceLicenseRef-PublicDomain
  • SourceNormal.hs
datadata Normal a
#

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.

Instances4CDF, Distribution, PDF

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.

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).