Continuous random variables

A-Level Mathematics · Probability & Statistics — Further

The probability density function

A function $f$ is a valid pdf when $f(x)\ge 0$ everywhere and

$$\int_{-\infty}^{\infty}f(x)\,dx=1$$

Probability is area: $P(a\lt X\lt b)=\displaystyle\int_{a}^{b}f(x)\,dx$. Consequently $P(X=c)=0$ for every single value $c$, so strict and non-strict inequalities give the same probability — unlike the discrete case.

Expectation, variance, median

$$\text{E}(X)=\int xf(x)\,dx,\qquad \text{E}\left(X^{2}\right)=\int x^{2}f(x)\,dx,\qquad \text{Var}(X)=\text{E}\left(X^{2}\right)-\big[\text{E}(X)\big]^{2}$$

The median $m$ splits the area in half:

$$\int_{-\infty}^{m}f(x)\,dx=\tfrac{1}{2}$$

The cumulative distribution function

$$F(x)=P(X\le x)=\int_{-\infty}^{x}f(t)\,dt,\qquad f(x)=F'(x)$$

$F$ must be written piecewise: $0$ below the range, the integral inside it, and $1$ above.

0 2 4 area = 0.5 median = 2 (read from symmetry) f(x) f(x) is NOT a probability — only area is bounded by 1
When you do not need integration to find the median. The graph of $f(x)=\dfrac{3}{32}x(4-x)$ is symmetric about $x=2$, so half the area lies on each side and the median is exactly $2$ — no equation to solve. The expectation is also $2$ for the same reason. This is a gift that exam questions often hand out and candidates often overlook: recognizing the symmetry before picking up your pen saves two integrations. But be careful, this property is true only when $f$ is symmetric; with a skewed density, the median and the expectation differ and each must be calculated separately.

Worked example: find the normalizing constant and the expectation

A continuous random variable $X$ has probability density function $f(x)=kx(4-x)$ for $0\le x\le 4$, and $0$ elsewhere. Find $k$, then find $\text{E}(X)$ and $\text{Var}(X)$.

Solution

Step 1 — normalizing constant. The total area must equal $1$:

$$\int_{0}^{4}k\left(4x-x^{2}\right)dx=k\left[2x^{2}-\frac{x^{3}}{3}\right]_{0}^{4}=k\left(32-\frac{64}{3}\right)=k\cdot\frac{32}{3}=1$$$$k=\frac{3}{32}$$

Step 2 — expectation. The graph is symmetric about $x=2$, so we can read off $\text{E}(X)=2$ immediately; the calculation below confirms it:

$$\text{E}(X)=\int_{0}^{4}x\cdot\frac{3}{32}\left(4x-x^{2}\right)dx=\frac{3}{32}\left[\frac{4x^{3}}{3}-\frac{x^{4}}{4}\right]_{0}^{4}=\frac{3}{32}\left(\frac{256}{3}-64\right)=\frac{3}{32}\cdot\frac{64}{3}=2$$

Step 3 — variance.

$$\text{E}\left(X^{2}\right)=\frac{3}{32}\int_{0}^{4}\left(4x^{3}-x^{4}\right)dx=\frac{3}{32}\left[x^{4}-\frac{x^{5}}{5}\right]_{0}^{4}=\frac{3}{32}\left(256-\frac{1024}{5}\right)=\frac{3}{32}\cdot\frac{256}{5}=\frac{24}{5}$$$$\text{Var}(X)=\frac{24}{5}-2^{2}=\frac{24-20}{5}=\frac{4}{5}=0.8$$

Sense check: $X$ ranges over an interval $4$ units long but is concentrated toward the middle, so the standard deviation $\sqrt{0.8}=0.89$ is much smaller than half the width of the interval. Reasonable.

Worked example: from density to cumulative distribution function

Given $f(x)=\dfrac{x}{2}$ for $0\le x\le 2$ and $0$ elsewhere. Find the cumulative distribution function $F$, and use it to find the median.

Solution

Step 1 — integrate within the range.

$$F(x)=\int_{0}^{x}\frac{t}{2}\,dt=\left[\frac{t^{2}}{4}\right]_{0}^{x}=\frac{x^{2}}{4}\qquad(0\le x\le 2)$$

Step 2 — write all three pieces. This is the most commonly forgotten step, and it has its own mark:

$$F(x)=\begin{cases}0 & x<0\\[4pt] \dfrac{x^{2}}{4} & 0\le x\le 2\\[4pt] 1 & x>2\end{cases}$$

Check both endpoints: $F(0)=0$ and $F(2)=\dfrac{4}{4}=1$. If $F(2)$ does not come out as $1$, the normalizing constant was certainly wrong earlier.

Step 3 — median. The median is the value that makes $F$ equal to $\dfrac{1}{2}$:

$$\frac{m^{2}}{4}=\frac{1}{2}\;\Longrightarrow\;m^{2}=2\;\Longrightarrow\;m=\sqrt{2}\approx 1.41$$

Notice that the median $1.41$ is greater than the midpoint of the interval ($1$), exactly as it should be: the density increases, so the probability mass is pushed to the right. The expectation here is $\dfrac{4}{3}\approx 1.33$, which also differs from the median — this density is not symmetric, so the shortcut must not be used.

Common mistake

Treating $f(x)$ as a probability, or using the discrete formulas for a continuous variable. There are three common forms. First, the conclusion “$f(1.5)=0.75$ so $P(X=1.5)=0.75$” — wrong, because for a continuous variable $P(X=c)=0$ for every $c$, and $f$ is only a density, which can exceed $1$ without any contradiction. Second, distinguishing $P(X<1)$ from $P(X\le 1)$ — these two values are equal in the continuous case, so do not waste effort adding or subtracting. Third, calculating $\text{E}(X)$ by summing $\sum xf(x)$ over a few points instead of integrating. The fundamental way to tell them apart: discrete means sum, continuous means integrate, and the sign that you have a continuous case is that the question gives a function on an interval rather than a table of values.

Key takeaway

The entire continuous-variable topic rests on one single idea: probability equals area. The normalizing constant makes the total area equal $1$; the median splits the area in half; the cumulative function is the area accumulated from the left. Remember it in terms of area and you never have to memorize four separate formulas.

← The Poisson distribution and linear combinations · All A-Level Mathematics lessons · Practice A-Level Mathematics questions (free, instant scoring) · Sampling, estimation and hypothesis testing →