Lesson 3 of 8 · 18 min

Cumulative distribution functions and the median

Build the cumulative distribution function F(x)=P(X≤x)F(x) = P(X \le x) from a density, use it to find probabilities, and solve F(m)=0.5F(m) = 0.5 for the median and other quantiles.

What you will be able to do

  • Define F(x)=P(X≤x)F(x) = P(X \le x) and find it by integrating the pdf from the left end of the support.
  • Write F(x)F(x) piecewise, including where it is 0 and where it is 1.
  • Use P(a<X≤b)=F(b)−F(a)P(a < X \le b) = F(b) - F(a) and F′(x)=p(x)F'(x) = p(x).
  • Find the median and other quantiles by solving F(x)=F(x) = a given proportion.

Every probability so far has needed a fresh integral. If you will be asked many questions of the form "what is the chance XX is at most …?", it is quicker to do the integral once with a variable upper limit. The result is a function that keeps a running total of the area from the left: the cumulative distribution function.

Definition

Cumulative distribution function

The cumulative distribution function (cdf) of XX is

F(x)=P(X≤x)=∫−∞xp(t) dt.F(x) = P(X \le x) = \int_{-\infty}^{x} p(t)\,dt.

If the support of pp starts at aa, this is F(x)=∫axp(t) dtF(x) = \int_a^x p(t)\,dt for xx in the support. The variable of integration is renamed tt because xx is now a limit.

FF is 0 to the left of the support, rises (never falls) through it, and equals 1 to the right of it. Because FF is an integral of pp, the fundamental theorem of calculus gives F′(x)=p(x)F'(x) = p(x).

Worked example

Find the cdf and median of p(x)=x8p(x) = \frac{x}{8}

  • Complex familiar
  • Technology free

XX has pdf p(x)=x8p(x) = \frac{x}{8} for 0≤x≤40 \le x \le 4, and p(x)=0p(x) = 0 elsewhere.

(a) Find the cumulative distribution function F(x)F(x).

(b) Use FF to find P(1<X≤3)P(1 < X \le 3).

(c) Find the exact median of XX.

5 steps

Try it yourself first, then check the working one step at a time.

Method

  1. F(x)=∫axp(t) dtF(x) = \int_a^x p(t)\,dt from the left end aa of the support.

  2. Write all three pieces and check F=0F = 0 and 11 at the ends.

  3. Probabilities: F(b)−F(a)F(b) - F(a). Median: solve F(m)=0.5F(m) = 0.5 inside the support.

Watch out for

  • Giving the median as 2, the middle of the interval: that only works for a symmetric density.

  • Keeping the negative square root.

The cdf F(x)=x216F(x) = \frac{x^2}{16} of p(x)=x8p(x) = \frac{x}{8} on [0,4][0, 4], written piecewise. The median is where FF reaches 0.5.

A random variable has cumulative distribution function F(x)=x327F(x) = \frac{x^3}{27} for 0≤x≤30 \le x \le 3, with F(x)=0F(x) = 0 for x<0x < 0 and F(x)=1F(x) = 1 for x>3x > 3. Find P(1<X<2)P(1 < X < 2).

Reads asYour answer shows here as maths.

Key idea

The median and other quantiles

The median mm splits the area under the pdf in half:

F(m)=P(X≤m)=0.5.F(m) = P(X \le m) = 0.5.

In the same way the lower quartile q1q_1 solves F(q1)=0.25F(q_1) = 0.25, the upper quartile solves F(q3)=0.75F(q_3) = 0.75, and the 90th percentile solves F(x)=0.9F(x) = 0.9. Always keep the solution that lies inside the support.

Interactive

The running total of area

The density p(x)=38x2p(x) = \frac{3}{8}x^2 on [0,2][0, 2] with its cdf F(x)=x38F(x) = \frac{x^3}{8}. Move the shading boundary: the shaded area is FF at that point. Where does the area reach one half?

For p(x)=38x2p(x) = \frac{3}{8}x^2 on 0≤x≤20 \le x \le 2, the cdf is F(x)=x38F(x) = \frac{x^3}{8} on that interval. Find the exact median.

m =
Reads asYour answer shows here as maths.

Common mistake

The cdf needs the right starting point

F(x)F(x) is the integral from the left end of the support, not just any antiderivative. For p(x)=16p(x) = \frac{1}{6} on [2,8][2, 8], an antiderivative is x6\frac{x}{6}, but F(x)=∫2x16 dt=x−26F(x) = \int_2^x \frac{1}{6}\,dt = \frac{x - 2}{6}. Check: FF must equal 0 at the left end and 1 at the right end.

A random variable has cdf F(x)=1−e−x/2F(x) = 1 - e^{-x/2} for x≥0x \ge 0 (and 0 for x<0x < 0). Which is its probability density function for x≥0x \ge 0?

Choose one answer

Worked example

Setting a warranty for an appliance

  • Complex unfamiliar

The lifetime TT years of a brand of dishwasher motor is modelled by

p(t)={0.2e−0.2t,t≥00,t<0.p(t) = \begin{cases} 0.2e^{-0.2t}, & t \ge 0 \\ 0, & t < 0. \end{cases}

(a) Show that p(t)p(t) is a probability density function.

(b) Find the cumulative distribution function for t≥0t \ge 0.

(c) Find the probability that a motor lasts more than 10 years, correct to 4 decimal places.

(d) Find the median lifetime, correct to 2 decimal places.

(e) The company wants to replace free of charge no more than 10% of motors. How long, in months, should the warranty be?

7 steps

Try it yourself first, then check the working one step at a time.

Method

  1. For a valid pdf, show p≥0p \ge 0 and total area 1 (use a large upper limit for an unbounded support).

  2. F(t)=∫0tp(u) duF(t) = \int_0^t p(u)\,du; upper tails are 1−F1 - F.

  3. For any quantile, solve F(x)=qF(x) = q with logarithms.

Watch out for

  • Writing ∫0.2e−0.2t dt=0.2e−0.2t\int 0.2e^{-0.2t}\,dt = 0.2e^{-0.2t}: dividing by −0.2-0.2 gives −e−0.2t-e^{-0.2t}.

  • Rounding the warranty up to 7 months, which lets more than 10% fail.

Exam tip

Write F piecewise

When asked to "find the cumulative distribution function", give all three pieces: F(x)=0F(x) = 0 for xx below the support, the formula on the support, and F(x)=1F(x) = 1 above it. Then check FF is 0 and 1 at the two ends.

Summary

  • F(x)=P(X≤x)=∫−∞xp(t) dtF(x) = P(X \le x) = \int_{-\infty}^{x} p(t)\,dt: the area to the left of xx.

  • FF is 0 below the support, non-decreasing, and 1 above it; F′(x)=p(x)F'(x) = p(x).

  • P(a<X≤b)=F(b)−F(a)P(a < X \le b) = F(b) - F(a) and P(X>a)=1−F(a)P(X > a) = 1 - F(a).

  • The median solves F(m)=0.5F(m) = 0.5; quartiles and percentiles solve F(x)=0.25,0.75,0.9,…F(x) = 0.25, 0.75, 0.9, \ldots

  • Start the integral at the left end of the support so that FF starts at 0.

Finished the lesson?

Try the 3 quick checks above and the lesson completes itself, or mark it complete now.

Lesson 3 of 80% read

Save your progress with a free account