Skip to content
LeetQuant
F1 Mathematical Reasoning and Calculus

F1 · Mathematical Reasoning and Calculus · Lesson 4 of 6

Integration Techniques for Densities

Substitution, integration by parts, normalising densities, expectations as integrals, and the Gamma, Beta and Gaussian integrals that make most of them one-liners.

18 min

What you actually need to integrate

Continuous probability is integration. A density ff satisfies f≥0f \ge 0 and ∫f=1\int f = 1; probabilities are P(X∈A)=∫AfP(X \in A) = \int_A f and expectations are E[g(X)]=∫g(x)f(x) dx\mathbb{E}[g(X)] = \int g(x)f(x)\,dx. The integrands that appear are almost always polynomials, exponentials, Gaussians and their products, so a few techniques and three named integrals do most of the work.

Substitution

∫f(g(x))g′(x) dx=∫f(u) du\int f(g(x))g'(x)\,dx = \int f(u)\,du with u=g(x)u = g(x). Look for a function whose derivative is also present. For the standard normal density φ(z)=12πe−z2/2\varphi(z) = \frac{1}{\sqrt{2\pi}}e^{-z^2/2}, the substitution u=z2/2u = z^2/2, du=z dzdu = z\,dz gives

E[Z+]=∫0∞zφ(z) dz=12π∫0∞e−u du=12π≈0.399.\mathbb{E}[Z^+] = \int_0^\infty z\varphi(z)\,dz = \frac{1}{\sqrt{2\pi}}\int_0^\infty e^{-u}\,du = \frac{1}{\sqrt{2\pi}} \approx 0.399 .

That number is behind the trader's rule that an at-the-money call is worth about 0.4 SσT0.4\,S\sigma\sqrt T: with S=100S = 100, σ=20%\sigma = 20\%, T=1T = 1 and zero rates, roughly $8.

Integration by parts

∫u dv=uv−∫v du\int u\,dv = uv - \int v\,du. Choose uu to be the factor that gets simpler when differentiated (a polynomial) and dvdv the factor you can integrate (an exponential). For λ>0\lambda > 0:

∫0∞xλe−λx dx=[−xe−λx]0∞+∫0∞e−λx dx=1λ.\int_0^\infty x\lambda e^{-\lambda x}\,dx = \Big[-xe^{-\lambda x}\Big]_0^\infty + \int_0^\infty e^{-\lambda x}\,dx = \frac1\lambda .

Repeating it nn times gives the most useful formula in this lesson:

∫0∞xne−λx dx=n!λn+1.\int_0^\infty x^n e^{-\lambda x}\,dx = \frac{n!}{\lambda^{n+1}} .

Completing the square

For Gaussian integrands with a linear term in the exponent, complete the square: tz−12z2=12t2−12(z−t)2tz - \tfrac12z^2 = \tfrac12t^2 - \tfrac12(z - t)^2, so

E[etZ]=∫etzφ(z) dz=et2/2∫φ(z−t) dz=et2/2.\mathbb{E}[e^{tZ}] = \int e^{tz}\varphi(z)\,dz = e^{t^2/2}\int \varphi(z - t)\,dz = e^{t^2/2} .

The named integrals

NameIntegralValue
GammaΓ(a)=∫0∞xa−1e−x dx\Gamma(a) = \int_0^\infty x^{a-1}e^{-x}\,dxΓ(n)=(n−1)!\Gamma(n) = (n - 1)!,  Γ(12)=π\ \Gamma(\tfrac12) = \sqrt\pi,  Γ(a+1)=aΓ(a)\ \Gamma(a + 1) = a\Gamma(a)
BetaB(a,b)=∫01xa−1(1−x)b−1 dxB(a, b) = \int_0^1 x^{a-1}(1 - x)^{b-1}\,dxΓ(a)Γ(b)Γ(a+b)\dfrac{\Gamma(a)\Gamma(b)}{\Gamma(a + b)}; for integers (a−1)! (b−1)!(a+b−1)!\dfrac{(a-1)!\,(b-1)!}{(a+b-1)!}
Gaussian∫−∞∞e−x2/2 dx\int_{-\infty}^\infty e^{-x^2/2}\,dx2π\sqrt{2\pi}

With these, you recognise an integral instead of computing it: if the integrand looks like a known density up to a constant, the integral is the reciprocal of that density's normalising constant.

Expectation from the tail

For X≥0X \ge 0, E[X]=∫0∞P(X>x) dx\mathbb{E}[X] = \int_0^\infty P(X > x)\,dx. This is often easier than finding the density, especially for minima and maxima. For the minimum of three independent uniforms on [0,1][0, 1], P(min⁡>x)=(1−x)3P(\min > x) = (1 - x)^3, so E[min⁡]=∫01(1−x)3 dx=14\mathbb{E}[\min] = \int_0^1 (1 - x)^3\,dx = \tfrac14.

Worked example

normalise, then take moments

(a) Find cc so that f(x)=cx(1−x)f(x) = cx(1 - x) is a density on [0,1][0, 1], and compute its mean and variance.

(b) Find cc so that f(x)=cx2e−xf(x) = cx^2e^{-x} is a density on (0,∞)(0, \infty), and compute its mean and variance.

Show solution

(a) ∫01x(1−x) dx=12−13=16\int_0^1 x(1 - x)\,dx = \tfrac12 - \tfrac13 = \tfrac16, so c=6c = 6. By symmetry about 12\tfrac12, E[X]=12\mathbb{E}[X] = \tfrac12. Next,

E[X2]=6∫01x3(1−x) dx=6(14−15)=310,\mathbb{E}[X^2] = 6\int_0^1 x^3(1 - x)\,dx = 6\left(\tfrac14 - \tfrac15\right) = \tfrac{3}{10},

so Var⁡(X)=0.3−0.25=0.05\operatorname{Var}(X) = 0.3 - 0.25 = 0.05. This is the Beta(2, 2) density, and 6=1/B(2,2)=3!/(1! 1!)6 = 1/B(2, 2) = 3!/(1!\,1!).

(b) ∫0∞x2e−x dx=Γ(3)=2!=2\int_0^\infty x^2e^{-x}\,dx = \Gamma(3) = 2! = 2, so c=12c = \tfrac12. Moments are just shifted Gamma integrals:

E[X]=12Γ(4)=3,E[X2]=12Γ(5)=12,Var⁡(X)=12−9=3.\mathbb{E}[X] = \tfrac12\Gamma(4) = 3, \qquad \mathbb{E}[X^2] = \tfrac12\Gamma(5) = 12, \qquad \operatorname{Var}(X) = 12 - 9 = 3 .

This is a Gamma(3, 1) variable, the sum of three independent Exp(1) waiting times, which is why the mean and the variance are both 3.

Worked example

a payoff and a Beta integral

(a) SS is exponential with mean 1. Compute E[(S−K)+]\mathbb{E}[(S - K)^+] for K≥0K \ge 0.

(b) UU is uniform on [0,1][0, 1]. Compute E[U2(1−U)3]\mathbb{E}[U^2(1 - U)^3].

Show solution

(a) The payoff is zero below KK, so

E[(S−K)+]=∫K∞(s−K)e−s ds.\mathbb{E}[(S - K)^+] = \int_K^\infty (s - K)e^{-s}\,ds .

Substitute u=s−Ku = s - K: ∫0∞ue−(u+K) du=e−K∫0∞ue−u du=e−K\int_0^\infty ue^{-(u + K)}\,du = e^{-K}\int_0^\infty ue^{-u}\,du = e^{-K}. (Equivalently, the exponential is memoryless: given S>KS > K, the excess S−KS - K is again Exp(1) with mean 1, and P(S>K)=e−KP(S > K) = e^{-K}.) At K=1K = 1 this is e−1≈0.368e^{-1} \approx 0.368.

(b) The density of UU is 1 on [0,1][0, 1], so this is B(3,4)=2! 3!6!=12720=160B(3, 4) = \dfrac{2!\,3!}{6!} = \dfrac{12}{720} = \dfrac{1}{60}. Expanding (1−u)3(1 - u)^3 and integrating term by term gives the same answer much more slowly.

Knowledge check

For which cc is f(x)=cx3f(x) = cx^3 a density on [0,2][0, 2]?

Knowledge check

What is ∫0∞x3e−2x dx\int_0^\infty x^3e^{-2x}\,dx?

Knowledge check

For a standard normal ZZ, what is E∣Z∣\mathbb{E}\lvert Z \rvert, to two decimal places?

Knowledge check

What is ∫01x4(1−x)4 dx\int_0^1 x^4(1 - x)^4\,dx?

Key takeaways

  • Substitution when a function and its derivative both appear; parts when a polynomial multiplies an exponential.
  • ∫0∞xne−λx dx=n!/λn+1\int_0^\infty x^ne^{-\lambda x}\,dx = n!/\lambda^{n+1}, ∫01xa−1(1−x)b−1 dx=(a−1)!(b−1)!(a+b−1)!\int_0^1 x^{a-1}(1 - x)^{b-1}\,dx = \frac{(a-1)!(b-1)!}{(a+b-1)!}, ∫e−x2/2=2π\int e^{-x^2/2} = \sqrt{2\pi}.
  • Normalise first, then read moments off the same named integral with shifted parameters.
  • Complete the square for Gaussians: E[etZ]=et2/2\mathbb{E}[e^{tZ}] = e^{t^2/2}.
  • For non-negative XX, E[X]=∫0∞P(X>x) dx\mathbb{E}[X] = \int_0^\infty P(X > x)\,dx is often the quickest route.
  • E[Z+]=1/2π≈0.4\mathbb{E}[Z^+] = 1/\sqrt{2\pi} \approx 0.4, the source of the at-the-money option rule of thumb.

Practice problems

Finished reading?

Answer the 4 knowledge checks to complete this lesson (0 done).