10
$\begingroup$

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$?

$\endgroup$
  • $\begingroup$ johndcook.com/erf_and_normal_cdf.pdf $\endgroup$ – Mark L. Stone Dec 21 '15 at 22:54
  • $\begingroup$ I saw this, but it starts with ERF already defined. $\endgroup$ – TH4454 Dec 21 '15 at 22:57
  • $\begingroup$ 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. $\endgroup$ – Mark L. Stone Dec 21 '15 at 23:43
  • $\begingroup$ 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? $\endgroup$ – TH4454 Dec 22 '15 at 0:13
  • $\begingroup$ Are you familiar with the calculus technique of change of variable? If not, learn how to do it. $\endgroup$ – Mark L. Stone Dec 22 '15 at 0:19
16
$\begingroup$

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.


By definition, the Error Function is

$$\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.

Figure

$\endgroup$
  • $\begingroup$ 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. $\endgroup$ – Foad Apr 18 '18 at 17:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.