IB Diploma Mathematics AA · Statistics and probability
Continuous random variables (HL)
1Probability density functions
A continuous random variable can take any value in an interval. It is described by a probability density function (pdf) $f(x)$.
A probability density function: probability is area under the curve
- $f(x) \ge 0$ for all $x$.
- The total area is 1: $\int f(x)\,dx = 1$ over all possible $x$.
- Probability is area: $P(a < X < b) = \int_a^b f(x)\,dx$.
$f(x)$ itself is not a probability. It can even be bigger than 1, as long as the total area is 1.
Finding k
- $f(x) = kx(4 - x)$ for $0 \le x \le 4$, and 0 otherwise.
- $\int_0^4 kx(4 - x)\,dx = k\left[2x^2 - \frac{x^3}{3}\right]_0^4 = k\left(32 - \frac{64}{3}\right) = \frac{32k}{3}$.
- Set equal to 1: $k = \frac{3}{32}$.
- $P(X < 1) = \frac{3}{32}\left[2x^2 - \frac{x^3}{3}\right]_0^1 = \frac{3}{32} \times \frac{5}{3} = \frac{5}{32} = 0.156$.
Check yourself
For a pdf f(x), what does the area under the curve between a and b give?
Show the answer
P(a < X < b)
For continuous variables, probability is area.
2Mode and median
- The mode is the value of $x$ where $f(x)$ is greatest. Find it by differentiating, or from the graph.
- The median $m$ splits the area in half:
$$\int_{\text{lower}}^{m} f(x)\,dx = 0.5$$
The median of a simple pdf
- $f(x) = \frac{x}{8}$ for $0 \le x \le 4$.
- $\int_0^m \frac{x}{8}\,dx = \frac{m^2}{16} = 0.5$.
- $m^2 = 8$, so $m = \sqrt{8} = 2.83$. Reject $-\sqrt{8}$, as it is outside the interval.
- The mode is $4$, where $f(x)$ is highest.
Check yourself
How do you find the median m of a continuous distribution?
Show the answer
Solve for m where the area up to m is 0.5
Half the probability lies on each side.
3Mean and variance
The mean and variance use integration in place of summation:
$$E(X) = \int x f(x)\,dx \qquad \text{Var}(X) = \int x^2 f(x)\,dx - [E(X)]^2$$
For f(x) = (3/32)x(4 − x)
- The graph is symmetric about $x = 2$, so $E(X) = 2$.
- $E(X^2) = \frac{3}{32}\int_0^4 (4x^3 - x^4)\,dx = \frac{3}{32}\left[x^4 - \frac{x^5}{5}\right]_0^4 = \frac{3}{32} \times \frac{256}{5} = 4.8$.
- $\text{Var}(X) = 4.8 - 2^2 = 0.8$.
For f(x) = x/8 on 0 to 4
- $E(X) = \int_0^4 \frac{x^2}{8}\,dx = \left[\frac{x^3}{24}\right]_0^4 = \frac{64}{24} = 2.67$.
- The mean (2.67) is less than the median (2.83), because the distribution has a long tail to the left.
The rules for linear changes still hold: $E(aX + b) = aE(X) + b$ and $\text{Var}(aX + b) = a^2\text{Var}(X)$.
Check yourself
Which formula gives E(X) for a continuous random variable?
Show the answer
∫ x f(x) dx
Weight each x by its density and integrate.
4Piecewise pdfs
Some pdfs are defined in pieces. Integrate each piece over its own interval and add.
A triangle-shaped pdf
- $f(x) = \frac{x}{2}$ for $0 \le x \le 1$, and $f(x) = \frac{3 - x}{4}$ for $1 < x \le 3$.
- Area of the first piece: $\int_0^1 \frac{x}{2}\,dx = \frac{1}{4}$.
- Area of the second piece: $\int_1^3 \frac{3 - x}{4}\,dx = \frac{1}{4}\left[3x - \frac{x^2}{2}\right]_1^3 = \frac{1}{4}(4.5 - 2.5) = \frac{1}{2}$.
- Total: $\frac{3}{4}$, which is not 1, so this is not a valid pdf as it stands.
Always check the total area before using a pdf.
Check yourself
A pdf is defined in two pieces. How do you find the total area?
Show the answer
Integrate each piece over its own interval and add
Each piece covers a different part of the interval.
5Finding a constant in a pdf
A probability density function must integrate to 1 over its domain.
$f(x) = kx^2$ for $0 \le x \le 3$
- $\int_0^3 kx^2\,dx = k\left[\frac{x^3}{3}\right]_0^3 = 9k$.
- Set $9k = 1$, so $k = \frac{1}{9}$.
- $P(X < 2) = \int_0^2 \frac{x^2}{9}\,dx = \frac{8}{27} \approx 0.296$.
Check yourself
What must the total area under a pdf equal?
Show the answer
1
Total probability.
6The median of a continuous variable
The median $m$ satisfies $\int_{a}^{m} f(x)\,dx = 0.5$.
$f(x) = \frac{x^2}{9}$ for $0 \le x \le 3$
- $\int_0^m \frac{x^2}{9}\,dx = \frac{m^3}{27} = 0.5$.
- $m^3 = 13.5$, so $m \approx 2.38$.
- Mean: $E(X) = \int_0^3 x \cdot \frac{x^2}{9}\,dx = \frac{1}{9}\left[\frac{x^4}{4}\right]_0^3 = \frac{81}{36} = 2.25$.
- Here the median is greater than the mean, because the distribution is negatively skewed.
Check yourself
What is E(X) for a continuous random variable with pdf f(x)?
Show the answer
∫ x f(x) dx over the domain
It weights each x by its density.
7Going deeper: one density function analysed completely
$f(x) = kx(4 - x)$ for $0 \le x \le 4$, and 0 otherwise.
- Find $k$: the total area is 1. $\int_0^4 k(4x - x^2)\,dx = k\left[2x^2 - \frac{x^3}{3}\right]_0^4 = k\left(32 - \frac{64}{3}\right) = \frac{32k}{3}$, so $k = \frac{3}{32}$.
- Mode: the maximum of $f$, at $x = 2$ (the vertex of the parabola).
- Mean: the curve is symmetric about $x = 2$, so $E(X) = 2$. In general $E(X) = \int x f(x)\,dx$.
- $E(X^2)$: $\frac{3}{32}\int_0^4 (4x^3 - x^4)\,dx = \frac{3}{32}\left[x^4 - \frac{x^5}{5}\right]_0^4 = \frac{3}{32}(256 - 204.8) = 4.8$.
- Variance: $4.8 - 2^2 = 0.8$. Standard deviation: about 0.894.
- A probability: $P(X < 1) = \frac{3}{32}\left[2x^2 - \frac{x^3}{3}\right]_0^1 = \frac{3}{32} \times \frac{5}{3} = \frac{5}{32} \approx 0.156$.
- Median: by symmetry, 2. In general solve $\int_a^m f(x)\,dx = 0.5$.
Worked example (a median without symmetry): $f(x) = 2x$ for $0 \le x \le 1$.
- $\int_0^m 2x\,dx = m^2 = 0.5$.
- $m = \frac{1}{\sqrt{2}} \approx 0.707$.
- The mean is $\int_0^1 2x^2\,dx = \frac{2}{3}$, which is less than the median: the distribution is skewed towards larger values, with a tail to the left.
Quartiles are found the same way: solve $\int_a^{q} f(x)\,dx = 0.25$ or $0.75$.
Requirements for a density function
- $f(x) \ge 0$ everywhere.
- The total area under the curve is 1.
- $f(x)$ itself is not a probability and can be greater than 1. Probabilities are areas.
- $P(X = a) = 0$ for any single value.
Piecewise functions: integrate each piece over its own interval and add. To find the median, first check which piece contains the halfway point by finding the area of the first piece.
Using the GDC: definite integrals may be evaluated numerically on calculator papers. Write down the integral you are evaluating to earn the method mark.
Common mistakes
- Finding the mode by integrating. The mode is where $f$ is largest: differentiate, or check the endpoints.
- Forgetting to subtract $[E(X)]^2$ in the variance.
- Integrating outside the interval where $f$ is non-zero.
Check yourself
f(x) = kx for 0 ≤ x ≤ 2 is a probability density function. What is k?
Show the answer
0.5
The area is k × 2² ÷ 2 = 2k, which must equal 1.
Now test yourself
This lesson has a 8-question quiz and 5 exam-style questions with mark schemes in Impera. Free, with your progress saved.
Practise in Impera