ProbabilityContinuous Random Variables

CDFs, Medians and Percentiles

F(x) = ∫ f(t) dt from −∞ to x, f = F′, and the median m solves F(m) = 1/2.

Not started Jump to practice

The CDF $F(x) = P(X \le x)$ works for every random variable. For a continuous one it is the area under the density to the left of $x$, and the first part of the Fundamental Theorem connects the two: the density is the CDF's rate of change.

Key idea

$$F(x) = \int_{-\infty}^{x} f(t)\,dt, \qquad F'(x) = f(x), \qquad P(a < X \le b) = F(b) - F(a).$$ The median $m$ solves $F(m) = \frac{1}{2}$; the $p$th percentile solves $F(x_p) = p$.

Why it works

$F(x)$ is an accumulation function of the density, so by the Fundamental Theorem it is continuous and $F' = f$ wherever $f$ is continuous. $F$ rises from 0 to 1 and never decreases, because the area keeps adding nonnegative pieces. For a density given in pieces, $F(x)$ must include all the area to the left of $x$, including whole earlier pieces.
A triangle-shaped density in two pieces, with its CDF. The CDF at any point includes all the area to its left; the median sits where the CDF reaches one half.

Worked examples

Worked example: A CDF and its median

$f(x) = 2x$ on $[0, 1]$. Find $F(x)$ and the median.
  1. For $0 \le x \le 1$: $F(x) = \int_{0}^{x} 2t\,dt = x^{2}$. Below 0, $F = 0$; above 1, $F = 1$.
  2. Median: $m^{2} = \frac{1}{2}$, so $m = \frac{1}{\sqrt{2}} \approx 0.707$.
  3. The 25th percentile solves $x^{2} = \frac{1}{4}$: $x = \frac{1}{2}$.

Answer: $F(x) = x^{2}$ on $[0, 1]$; median $\frac{1}{\sqrt{2}}$.

Worked example: A density in two pieces

$f(x) = x$ on $[0, 1]$ and $f(x) = 2 - x$ on $[1, 2]$. Find $F(1.5)$, and a formula for $F$ on $[1, 2]$.
  1. The whole left piece has area $\int_{0}^{1} x\,dx = \frac{1}{2}$.
  2. For $1 \le x \le 2$: $$F(x) = \frac{1}{2} + \int_{1}^{x} (2 - t)\,dt = \frac{1}{2} + 2x - \frac{x^{2}}{2} - \frac{3}{2} = -\frac{x^{2}}{2} + 2x - 1$$
  3. $F(1.5) = -\frac{9}{8} + 3 - 1 = \frac{7}{8}$. Check: $F(1) = \frac{1}{2}$ and $F(2) = 1$.

Answer: $F(1.5) = \frac{7}{8}$

Worked example: From the CDF back to the density

$F(x) = 1 - e^{-x/2}$ for $x \ge 0$ (and 0 for $x < 0$). Find the density and the median.
  1. $f(x) = F'(x) = \frac{1}{2}e^{-x/2}$ for $x > 0$.
  2. Median: $1 - e^{-m/2} = \frac{1}{2}$, so $e^{-m/2} = \frac{1}{2}$ and $m = 2\ln 2 \approx 1.386$.

Answer: $f(x) = \frac{1}{2}e^{-x/2}$; median $2\ln 2$.

Common mistake

Building $F(x)$ on a later piece from that piece alone, for example $\int_{1}^{x}(2 - t)\,dt$, and forgetting the $\frac{1}{2}$ of area already to the left. Check the joins: $F$ must be continuous, so its formula on each piece has to agree with the previous piece at the boundary, and the last piece must end at 1.

Practice

Pass with 3 right answers, the last 2 in a row. Each right answer earns 2 XP.

Loading practice…

Builds on

Leads to

Sources and further reading

  • Grinstead and Snell, Introduction to Probability (2nd revised edition, American Mathematical Society; free from Dartmouth College), chapter 2 (Continuous Probability Densities), section 2.2, cumulative distribution functions
  • MIT OpenCourseWare 18.05, Introduction to Probability and Statistics (Spring 2014), readings on cumulative distribution functions and quantiles
@teddyrookbook GitHub