Gaussian Distribution: How to calculate the Cumulative Distribution Formula (CDF) from the Probability Density Function (PDF)? + Error Function? 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!
 A: 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).
$$
