# Gaussian Distribution: How to calculate the Cumulative Distribution Formula (CDF) from the Probability Density Function (PDF)? + Error Function? [duplicate]

I understand that we can calculate the probability density function (PDF) by computing the derivative of the cumulative distribution formula (CDF), since the CDF is the antiderivative of the PDF.

I get the intuition for that (integrals denote the area under a curve, which is the accumulated probability under the curve of continuous functions).

I'm just wondering how to derive the CDF from the PDF of the Gaussian distribution, which is $$f(x) = \frac{1}{\sigma \sqrt{2 \pi}} e^{- \frac{1}{2} \left(\frac{x - \mu}{\sigma} \right)^2}$$

I'm guessing we integrate this from negative infinity to positive infinity, but how do we do the whole process? I've seen the answer, and for some reason the answer seems to involve the "error" function, which is this:

$$\text{erf} (z) = \frac{2}{\sqrt{\pi}} \int_0^z e^{-t^2} dt$$

If someone could explain how we derive the CDF from the PDF of Gaussian distribution, AND how that calculated CDF is related to the error function, I would be so grateful!

• Not every integral, even if it exists, can be expressed in closed form. College calculus courses show general methods and a few 'tricks' for getting numerical values of definite integrals, but it is not always admitted that some integrals can be 'evaluated' only by numerical methods. ("The truth, and nothing but the truth," but not necessarily "The whole truth.") The reason we need printed CDF tables for the std normal dist'n is that no analytic method is available for what you want. // In R stat software, the normal CDF pnorm relies on a rational approx accurate to double precision arith. – BruceET Apr 4 at 20:10
• You understand that the ERF is basically just restating the integral of the pdf... Just with a substitution $t = (x-\mu)/\sqrt (2)\sigma$ – seanv507 Apr 4 at 21:03

The antiderivative of a Gaussian function has no closed form, but the integral over $$\mathbb{R}$$ can be solved for in closed form: \begin{align} \int_{-\infty}^{\infty} \exp(-x^2) dx = \sqrt{\pi} . \end{align}
Since $$\exp(-x^2)$$ is an even function (graph is symmetric about the $$y$$-axis), we can split this into two equal parts $$\int_{0}^{\infty} \exp(-x^2) dx = \frac{\sqrt{\pi}}{2} = \int_{-\infty}^{0} \exp(-x^2) dx.$$
Using this last equality, we can integrate the pdf of the standard normal distribution $$\phi(x) = \frac{1}{\sqrt{2 \pi}} \exp \left( -\frac{1}{2} x^2 \right)$$ to find the cdf: \begin{align} \Phi(z) & = \int_{-\infty}^z \frac{1}{\sqrt{2 \pi}} \exp \left( -\frac{1}{2} t^2 \right) dt \\ & = \frac{1}{\sqrt{\pi}} \int_{-\infty}^{z/\sqrt{2}} \exp \left( - u^2 \right) du, \text{ with the substitution } u = \frac{t}{\sqrt{2}} \\ & = \frac{1}{\sqrt{\pi}} \left( \int_{-\infty}^0 \exp \left( - u^2 \right) du + \int_0^{z/\sqrt{2}} \exp \left( - u^2 \right) du \right) \\ & = \frac{1}{\sqrt{\pi}} \left( \frac{\sqrt{\pi}}{2} + \int_0^{z/\sqrt{2}} \exp \left( - u^2 \right) du \right) \\ & = \frac{1}{2} + \frac{1}{\sqrt{\pi}} \int_0^{z/\sqrt{2}} \exp \left( - u^2 \right) du \\ & = \frac{1}{2} \left( 1 + \frac{2}{\sqrt{\pi}} \int_0^{z/\sqrt{2}} \exp \left( - u^2 \right) du \right)\\ & = \frac{1}{2} \left(1 + \text{erf} \left( \frac{z}{\sqrt{2}} \right) \right) \\ \end{align}
And for a non-standard normal distribution with mean $$\mu$$ and standard deviation $$\sigma$$, we have $$F(x) = \Phi \left( \frac{x - \mu}{\sigma} \right) = \frac{1}{2} \left(1 + \text{erf} \left( \frac{x - \mu}{\sigma \sqrt{2}} \right) \right).$$