# How are the Error Function and Standard Normal distribution function related?

If the Standard Normal PDF is $$f(x) = \frac{1}{\sqrt{2\pi}} e^{-x^2/2}$$

and the CDF is $$F(x) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^x e^{-x^2/2}\mathrm{d}x\,,$$

how does this turn into an error function of $z$?

• johndcook.com/erf_and_normal_cdf.pdf Commented Dec 21, 2015 at 22:54
• I saw this, but it starts with ERF already defined. Commented Dec 21, 2015 at 22:57
• Well, there's a definition of erf and a definition of the Normal CDF.. The relations, derivable by some routine calculations, are shown as to how to convert between them, and how to convert between their inverses. Commented Dec 21, 2015 at 23:43
• Sorry, I don't see many of the details. For example, the CDF is from -Inf to x. So how does the ERF go from 0 to x? Commented Dec 22, 2015 at 0:13
• Are you familiar with the calculus technique of change of variable? If not, learn how to do it. Commented Dec 22, 2015 at 0:19

Because this comes up often in some systems (for instance, Mathematica insists on expressing the Normal CDF in terms of $\text{Erf}$), it's good to have a thread like this that documents the relationship.

$$\text{Erf}(x) = \frac{2}{\sqrt{\pi}}\int_0^x e^{-t^2} \mathrm{d}t.$$

Writing $t^2 = z^2/2$ implies $t = z / \sqrt{2}$ (because $t$ is not negative), whence $\mathrm{d}t = \mathrm{d}z/\sqrt{2}$. The endpoints $t=0$ and $t=x$ become $z=0$ and $z=x\sqrt{2}$. To convert the resulting integral into something that looks like a cumulative distribution function (CDF), it must be expressed in terms of integrals that have lower limits of $-\infty$, thus:

$$\text{Erf}(x) = \frac{2}{\sqrt{2\pi}}\int_0^{x\sqrt{2}} e^{-z^2/2}\mathrm{d}z = 2\left(\frac{1}{\sqrt{2\pi}}\int_{-\infty}^{x\sqrt{2}}e^{-z^2/2}\mathrm{d}z - \frac{1}{\sqrt{2\pi}}\int_{-\infty}^0 e^{-z^2/2}\mathrm{d}z\right).$$

Those integrals on the right hand size are both values of the CDF of the standard Normal distribution,

$$\Phi(x) = \frac{1}{\sqrt{2\pi}}\int_{-\infty}^x e^{-z^2/2} \mathrm{d}z.$$

Specifically,

$$\text{Erf}(x) = 2(\Phi(x\sqrt{2}) - \Phi(0)) = 2\left(\Phi(x\sqrt{2}) - \frac{1}{2}\right) = 2\Phi(x\sqrt{2}) - 1.$$

This shows how to express the Error Function in terms of the Normal CDF. Algebraic manipulation of that easily gives the Normal CDF in terms of the Error Function:

$$\Phi(x) = \frac{1 + \text{Erf}(x/\sqrt{2})}{2}.$$

This relationship (for real numbers, anyway) is exhibited in plots of the two functions. The graphs are identical curves. The coordinates of the Error Function on the left are converted to the coordinates of $\Phi$ on the right by multiplying the $x$ coordinates by $\sqrt{2}$, adding $1$ to the $y$ coordinates, and then dividing the $y$ coordinates by $2$, reflecting the relationship

$$\Phi(x\sqrt{2}) = \frac{\text{Erf}(x) + 1}{2}$$

in which the notation explicitly shows these three operations of multiplication, addition, and division.

• I think $$\Phi(x,\mu,\sigma)=\frac{1}{2}\left( 1+\text{Erf} \left( \frac{x-\mu}{\sigma\sqrt{2}} \right)\right)$$ is the correct way to relate them, considering the mean and standard deviation.