normalDistribution

fnreal normalDistribution(real x)

Standard normal distribution function.

The normal (or Gaussian, or bell-shaped) distribution is defined as:

normalDist(x) = 1/√(2π) ∫-∞x exp( - t2/2) dt = 0.5 + 0.5 * erf(x/sqrt(2)) = 0.5 * erfc(- x/sqrt(2))

To maintain accuracy at values of x near 1.0, use normalDistribution(x) = 1.0 - normalDistribution(-x).

References:

http://www.netlib.org/cephes/ldoubdoc.html,

G. Marsaglia, "Evaluating the Normal Distribution", Journal of Statistical Software 11, (July 2004).