Saturday, April 9, 2016

The cumulative distribution function (CDF) of the standard normal distribution: error function, or erf(x)

Cumulative distribution function[edit]

The cumulative distribution function (CDF) of the standard normal distribution, usually denoted with the capital Greek letter \Phi (phi), is the integral
\Phi(x)\; = \;\frac{1}{\sqrt{2\pi}} \int_{-\infty}^x e^{-t^2/2} \, dt
In statistics one often uses the related error function, or erf(x), defined as the probability of a random variable with normal distribution of mean 0 and variance 1/2 falling in the range [-x, x]; that is
\operatorname{erf}(x)\; =\; \frac{1}{\sqrt{\pi}} \int_{-x}^x e^{-t^2} \, dt
These integrals cannot be expressed in terms of elementary functions, and are often said to be special functions. However, many numerical approximations are known; see below.
The two functions are closely related, namely
 \Phi(x)\; =\; \frac12\left[1 + \operatorname{erf}\left(\frac{x}{\sqrt{2}}\right)\right]
For a generic normal distribution f with mean μ and deviation σ, the cumulative distribution function is
F(x)\;=\;\Phi\left(\frac{x-\mu}{\sigma}\right)\;=\; \frac12\left[1 + \operatorname{erf}\left(\frac{x-\mu}{\sigma\sqrt{2}}\right)\right]
The complement of the standard normal CDF, Q(x) = 1 - \Phi(x), is often called the Q-function, especially in engineering texts.[16][17] It gives the probability that the value of a standard normal random variable X will exceed x. Other definitions of the Q-function, all of which are simple transformations of \Phi, are also used occasionally.[18]
The graph of the standard normal CDF \Phi has 2-fold rotational symmetry around the point (0,1/2); that is, \Phi(-x) = 1 - \Phi(x). Its antiderivative (indefinite integral) \int \Phi(x)\, dx is \int \Phi(x)\, dx = x\Phi(x) + \phi(x).
  • The cumulative distribution function (CDF) of the standard normal distribution can be expanded by Integration by parts into a series:
\Phi(x)\; =\;0.5+\frac{1}{\sqrt{2\pi}}\cdot e^{-x^2/2}\left[x+\frac{x^3}{3}+\frac{x^5}{3\cdot 5}+\cdots+\frac{x^{2n+1}}{(2n+1)!!} + \cdots\right]
where !! denotes the double factorial. As an example, the following Pascal function approximates the CDF:
function CDF(x:extended):extended;
var value,sum:extended;
    i:integer;
begin
  sum:=x;
  value:=x;
  for i:=1 to 100 do
    begin
      value:=(value*x*x/(2*i+1));
      sum:=sum+value;
    end;
  result:=0.5+(sum/sqrt(2*pi))*exp(-(x*x)/2);
end;

No comments:

Post a Comment