Skip to content

normalCDF

Fabian Kindermann edited this page Apr 1, 2021 · 11 revisions
function normalCDF(x, mu, sigma)

Description:

Calculates the cumulative distribution function
$$
F(x) = \frac{1}{2} \cdot \left[1 + \text{erf}\left(\frac{x-\mu}{\sqrt{2\sigma^2}}\right)\right] \enspace \text{with} \enspace \text{erf}(x) = \frac{2}{\sqrt{\pi}}\cdot \int_{-\infty}^{x} e^{-t^2}\ dt
$$
of the normal distribution with mean and variance .

Input arguments:

  • real*8 :: x
    The point where to evaluate the cumulative distribution function of the normal distribution.

Optional arguments:

  • real*8 :: mu
    The mean of the distribution. If not present, the function uses mu = 0.
  • real*8 :: sigma
    The variance of the distribution. If not present, the function uses sigma = 1. Note that this input variable needs to be strictly greater than zero.

Return Value:

  • real*8 :: normalCDF
    The value of the cumulative distribution function at x.

References

  • Parts of this routine were copied and adapted from:
  • For further reading refer to:
    • Toral, R. & Colet, P. (2014). Stochastic Numerical Methods: An Introduction for Students and Scientists. Weinheim: Wiley.
    • Hill, D. (1973). Algorithm AS 66: The Normal Integral. Applied Statistics, 22(3), 424-427.
  • This routine is used in the following programs:
    • prog02_15.f90
    • prog04_04.f90
Clone this wiki locally