Take the 2-minute tour ×
Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

I'm looking for a way of integrating the following formula where ppf() is the percentile point function for the standard normal distribution, cdf() is its inverse, and A is a constant:

\begin{equation} \int_{0}^{1} cdf(ppf(x)-A)dx \end{equation}

I can do it with a monte carlo technique but I'm hoping there's a faster way! Thanks in advance if anyone can help...

share|improve this question
I have not. If that's the suggestion that makes the most sense, I'll try it. I need to do this in a software module -- if anyone could make a suggestion about a C package (preferably with Python wrapper) to do that, that would be a help! –  garyrob Mar 26 at 18:46
Ah, I see it's there in scipy, thanks! –  garyrob Mar 26 at 19:15

2 Answers 2

up vote 7 down vote accepted

Since the percentile point function is the inverse of the standard normal CDF $\Phi(\cdot)$, we can write the desired integral as $$\begin{align} \int_0^1 \Phi\left(\Phi^{-1}(x) - A\right)\, \mathrm dx &= \int_{-\infty}^\infty \Phi(y-A)\phi(y)\,\mathrm dy\\ &= \int_{-\infty}^\infty \left[\int_{-\infty}^{y-A} \phi(z)\,\mathrm dz\right]\phi(y)\,\mathrm dy\\ &= \int_{-\infty}^\infty \int_{-\infty}^{y-A} f_{Y,Z}(y,z)\,\mathrm dz \, \mathrm dy\\ &= P\{Z \leq Y-A\}\\ &= P\{Y-Z \geq A\}\\ &= 1 - \Phi\left(\frac{A}{\sqrt{2}}\right) \end{align}$$ where we have

  • used $\phi(\cdot)$ to denote the standard normal pdf

  • substituted $x = \Phi(y)$, $\mathrm dx = \phi(y)\,\mathrm dy$, $x=0 \to y = -\infty$, $x=1 \to y = \infty$ as in whuber's answer,

  • replaced $\Phi(y-A)$ by its definition as the integral of $\phi(\cdot)$

  • recognized the integrand as the joint density of two independent standard normal random variables $Y$ and $Z$

  • recognized that the double integral gives $P\{Z \leq Y-A\}$

  • recognized that $Y-Z$ is a zero-mean normal random variable with variance $2$

The final result is the same as that given in whuber's answer.

share|improve this answer
(+1) Although the mathematics is essentially the same as in my answer, the focus on expressions that have probabilistic meaning provides a welcome clarity and simplicity. Note that only the very last equality made any assumption about the distribution apart from its continuity. –  whuber Mar 26 at 21:17
Awesome! Thanks so much! I had no idea it could come out to such a simple final calc. I'm going to mark @Dilip's as the answer because his explanation is so good, but equal thanks to @whuber! –  garyrob Mar 26 at 23:12

Let $f$ be the standard normal PDF and $F$ the CDF. Substituting $x=F(y)$ gives

$$g(a) = \int_0^1 F(F^{-1}(x)-a)dx = \int_{-\infty}^\infty F(y-a)f(y)dy.$$

The derivative of this expression with respect to $a$ can be found by differentiating under the integral sign, whence

$$\frac{dg(a)}{da} = -\int_{-\infty}^\infty f(y-a)f(y)dy= -\int_{-\infty}^\infty f(a-y)f(y)dy$$

because $f$ is an even function. The integral is the formula for the PDF of the sum of two standard Normal variables, which will therefore have mean $0$ and standard deviation $\sqrt{2}$.

Integrating with respect to $a$ to reverse the differentiation demonstrates that $g(a)$ is the negative of the CDF of a Normal$(0, \sqrt{2})$ variable, up to an additive constant of integration. Since the limiting value of $g$ as $a\to\infty$ is obviously $0$ and the limiting value of the CDF is $1$, the constant of integration must equal $1$. Therefore

$$g(a) = 1 - F\left(\frac{a}{\sqrt{2}}\right).$$

Consequently, any method to compute a Normal CDF will do the job.

There is a simple graphical interpretation of this result based on the probability integral transform. Recall that the CDF $F_X$ of an absolutely continuous distribution re-expresses the variable $X$ as a value $F_X(X)$ which has a uniform distribution. Moreover, $F$ is invertible with inverse $F^{-1}$. Assuming $\xi$ and $\eta$ are independently distributed with distribution $F$, consider the event

$$A = \{(\xi, \eta)\ |\ \xi-\eta\gt a\}.$$

This is depicted by the region beneath the surface in the left-hand plot and by the colored region in the middle plot, both shown on $(\xi,\eta)$ axes:


The value $a=-3/2$ is illustrated.

When $\xi$ is re-expressed as $x = F(\xi)$ and $\eta$ as $y=F(\eta)$, $A$ can be written as

$$A = \{(x, y)\ |\ F^{-1}(x) - F^{-1}(y)\gt a\}.$$

This is the shaded region on the right hand plot, which is shown in the re-expressed $(x,y)$ coordinates. To show more clearly the re-expression, I have labeled the axes in this plot with the corresponding $(\xi, \eta)$ values, so that the grid lines in the middle plot match the grid lines in this plot. The simultaneous re-expression of $\xi$ and $\eta$ has turned the boundary of $A$, which was a line $\xi-\eta=a$ on the left, into a curvilinear boundary.

The key point is that the variable density shown in the left and middle plots (the joint density of $\xi$ and $\eta$) becomes uniform in the right plot. This reduces questions of finding probabilities--which involve integrating the joint PDF over $A$--to those of finding areas.

Solving for $y$ shows us that $A$ is the region under the graph

$$y = F(F^{-1}(x) - a)$$

which extends only from $x=0$ through $x=1$. That is, when both $\xi$ and $\eta$ have densities given by $F$,

$${\Pr}_X(\xi-\eta\gt a)={\Pr}_X(A) = \int_0^1 F(F^{-1}(x) - a)dx = g(a).$$

This perfectly general result, when applied to a standard normal distribution, easily produces the earlier answer.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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