This whole subtopic is higher level. Nothing in it is on an SL paper.
Educerie · IB Diploma · Mathematics: analysis and approaches
Topic 4 Statistics and probability · 4.14 Discrete and continuous random variables
What you must be able to do
| You must be able to | Level | What it looks like in the exam |
|---|---|---|
| Find E(X), E(X²), Var(X) and the standard deviation of a discrete random variable | HL only | "Find Var(X)" from a table or a formula such as P(X = x) = kx² (3 to 4 marks) |
| Use E(X) = 0 to decide whether a game is fair, and find the fee that makes it fair | HL only | "Find the value of c for which the game is fair" (3 marks) |
| State and use the properties of a probability density function, including ∫ f(x) dx = 1 and piecewise functions | HL only | "Show that k = 4/27" (2 to 3 marks), Paper 1 |
| Find probabilities for a continuous random variable by integration | HL only | "Find P(1 < X < 2)" (2 to 3 marks) |
| Find the mode as the value where f(x) is greatest | HL only | "Find the mode of X" (2 to 3 marks), by differentiation or from the graph |
| Find the median m from ∫ f(x) dx = 1/2 up to m | HL only | "Find the median of X" (3 to 4 marks), by hand on Paper 1 or with the GDC on Paper 2 |
| Find the mean, variance and standard deviation of a continuous random variable | HL only | "Find E(X)" and "find Var(X)" (3 to 5 marks each) |
| Use E(aX + b) = aE(X) + b and Var(aX + b) = a²Var(X) | HL only | "Hence find E(3X − 2) and Var(3X − 2)" (2 to 3 marks) |
Before you start
You need discrete random variables and expected value from 4.7: a probability distribution lists every value with its probability, the probabilities add to 1, and E(X) = Σ x P(X = x). From Topic 5 you need definite integration of polynomials by hand, differentiation to find a maximum, and your GDC's numerical integration and solver for Paper 2. The formula booklet gives E(X) for discrete and continuous variables, both forms of Var(X) for each, and the linear transformation rules. The definitions of mode and median are not printed.
1The idea in one paragraph
A random variable X is a number decided by chance. If its values can be listed, such as 0, 1, 2, 3 goals, it is discrete, and each value has a probability. If it can take any value in an interval, such as a waiting time, it is continuous: a single exact value has probability zero, and probability is the area under a curve called the probability density function, f(x). Either way, the same few numbers summarise it. The mean E(X) is its balance point. The variance Var(X) is the average squared distance from that mean, and its square root, the standard deviation, is a typical distance. For a continuous variable you also find the mode, where f is highest, and the median, which splits the area in half. Finally, if you convert X with a linear rule, aX + b, the mean follows the same rule but the variance only feels the a, squared.
2Discrete random variables: mean and variance
A football team's goals per match, X, have this distribution:
| x | 0 | 1 | 2 | 3 | 4 |
|---|---|---|---|---|---|
| P(X = x) | 0.2 | 0.35 | 0.25 | 0.15 | 0.05 |
The expected value or mean is the probability-weighted average, E(X) = Σ x P(X = x), which you met in 4.7.
No match ends with 1.5 goals; 1.5 is the long-run average, the point where the bar chart in Figure 1 balances.
The variance measures spread: the expected squared distance from the mean, Var(X) = E[(X − μ)²], where μ = E(X). The formula booklet gives it two ways:
Var(X) = Σ (x − μ)² P(X = x) = Σ x² P(X = x) − μ², that is, Var(X) = E(X²) − [E(X)]².
The second form is almost always quicker. E(X²) means the expected value of the square of X: square each value, weight by its probability, add.
Notice that E(X²) = 3.5 is not [E(X)]² = 2.25; the gap between them is the variance. The variance is in squared units (goals²), so the standard deviation, back in goals, is the one you interpret. Figure 1 marks both.
A distribution given by a formula (Paper 1). The random variable X has P(X = x) = kx² for x ∈ {1, 2, 3}. Find k, E(X) and Var(X).
The standard deviation is √19 ÷ 7 ≈ 0.623. Leave Paper 1 answers exact unless asked otherwise.
3Fair games
If X is a player's gain in a game (winnings minus the fee), the game is fair when E(X) = 0: in the long run nobody profits. It is not about winning as often as losing.
A charity stall charges $3 to spin a wheel. The wheel pays $10 with probability 0.1, $4 with probability 0.3, and nothing otherwise. Let W be the amount paid out.
The game is not fair: it favours the stall. It would be fair at a fee of $2.20. Insurers, casinos and lotteries price the same way, with E(gain) negative for the customer. The spread of the payout is E(W²) = 100(0.1) + 16(0.3) = 14.8, so Var(W) = 14.8 − 2.2² = 9.96; section 8 shows the gain W − 3 has the same variance.
4Continuous random variables and the probability density function
A continuous variable takes too many values to list, so instead a probability density function (pdf) f(x) is a curve whose area gives probability:
P(a ≤ X ≤ b) = ∫ₐᵇ f(x) dx, with f(x) ≥ 0 for all x and ∫ f(x) dx = 1 over all x (from −∞ to ∞).
Because single points have zero probability, P(X < 1) = P(X ≤ 1) for a continuous variable (not for a discrete one). And f(x) is not a probability; it is a density and can exceed 1: a variable spread evenly over [0, 0.5] has f(x) = 2 there, so that the area is 1. Usually f is a formula on an interval and 0 elsewhere, so "from −∞ to ∞" becomes "over that interval".
Example · finding k (Paper 1). A continuous random variable X has pdf f(x) = kx²(3 − x) for 0 ≤ x ≤ 3, and f(x) = 0 otherwise. Find k, then P(X < 1).
Figure 2 shows the curve with the total area of 1 and the shaded area 1/9. Also check the other condition: on [0, 3], x² ≥ 0 and 3 − x ≥ 0, so f(x) ≥ 0. A question saying "show that f is a valid pdf" wants both checks.
Similarly, P(1 < X < 2) = (4/27)[(8 − 4) − (1 − 1/4)] = (4/27)(13/4) = 13/27. On Paper 2 you would get 0.481 by numerical integration on the GDC; on Paper 1 you do exactly the working above.
5Mode and median of a continuous random variable
The guide defines both.
- The mode is a value of x at which the pdf f(x) has its maximum value. For a smooth curve, find it by solving f′(x) = 0 and checking it is a maximum; if f is increasing or decreasing across the whole interval, the maximum is at an endpoint.
- The median m is the value that splits the area in half: ∫ f(x) dx from −∞ to m = 1/2.
Mode. For f(x) = (4/27)(3x² − x³):
Justify the maximum: f′ changes from positive to negative at 2, or f(2) exceeds f at both endpoints, which are 0.
Median. You need (4/27)[m³ − m⁴/4] = 1/2, a quartic. On Paper 1 a question would choose a pdf where this comes out nicely (section 7 shows one); here it does not, so it is a Paper 2 job.
Reject any GDC solution outside [0, 3]. Figure 3 marks the mode, the median and the mean (found in the next section) on the same curve.
6Mean, variance and standard deviation of a continuous random variable
The continuous formulas are the discrete ones with the sum replaced by an integral and P(X = x) replaced by f(x) dx:
E(X) = μ = ∫ x f(x) dx and Var(X) = ∫ (x − μ)² f(x) dx = ∫ x² f(x) dx − μ², integrating over all x. From the formula booklet.
So E(X²) = ∫ x² f(x) dx and, exactly as before, Var(X) = E(X²) − [E(X)]². For the same pdf:
Multiply f(x) by x before integrating; ∫ f(x) dx on its own is just 1.
Look again at Figure 3. The mean 1.8 is below the median 1.84, which is below the mode 2. The curve has a long tail to the left, a negatively skewed distribution, and a tail drags the mean towards it more than it drags the median, because the mean weights each value by how far out it is. For a symmetric pdf all three coincide. This ordering is a useful check on your answers.
7Piecewise probability density functions
The guide includes piecewise functions: f is given by one rule on one interval and another rule on the next. Every property still holds, but each integral must be split at the join.
A random variable X has
f(x) = x/6 for 0 ≤ x ≤ 2, f(x) = (6 − x)/12 for 2 < x ≤ 6, and f(x) = 0 otherwise.
Figure 4 shows it: a triangle, rising in teal and falling in amber.
Check it is valid. Both pieces are non-negative on their intervals, and
Mode. The highest point is the peak of the triangle, f(2) = 1/3, so the mode is 2.
Median. The first piece holds only 1/3 of the area, less than 1/2, so the median is in the second piece. You need a further 1/2 − 1/3 = 1/6 of area beyond x = 2.
Deciding which piece holds the median before integrating is worth a mark.
Mean and variance. Split each integral at 2.
So mode 2 < median 2.54 < mean 2.67: this time the long tail is on the right, a positively skewed distribution, and the order reverses.
8Linear transformations: E(aX + b) and Var(aX + b)
If every value of X is multiplied by a and then has b added, the new variable is aX + b.
E(aX + b) = aE(X) + b and Var(aX + b) = a² Var(X). From the formula booklet.
Why. For a discrete X, E(aX + b) = Σ (ax + b)P(X = x) = aΣ x P(X = x) + bΣ P(X = x) = aE(X) + b, because the probabilities add to 1. The same step works with integrals. For the variance, each value's distance from the mean becomes (ax + b) − (aμ + b) = a(x − μ): the b cancels, and the distance is multiplied by a. Squaring gives a², so Var(aX + b) = a²Var(X), and the standard deviation becomes |a|σ.
Figure 5 shows it with the goals from section 2. A fantasy league scores a team 2 points per goal plus 1 point for playing, so its points are Y = 2X + 1.
Changing units. July maximum temperatures X °C have mean 18 and standard deviation 4. In °F, F = 1.8X + 32, so E(F) = 1.8(18) + 32 = 64.4 °F, Var(F) = 1.8² × 16 = 51.84 and the standard deviation is 7.2 °F. The + 32 moves the mean but not the spread.
Three cases that catch people. Var(X − 5) = Var(X), which is why the wheel's gain W − 3 has variance 9.96. Var(−X) = (−1)²Var(X) = Var(X). And Var(3 − 2X) = (−2)²Var(X) = 4Var(X), not −2Var(X) and not 4Var(X) + 3.
9Where marks are lost
E(X) = ∫ f(x) dx. That integral is 1 for every pdf. The mean needs ∫ x f(x) dx.
[E(X)]² for E(X²). E(X²) is found by squaring the values, then averaging: Σ x²P(X = x) or ∫ x² f(x) dx. Squaring the mean instead makes the variance come out as 0.
Forgetting to subtract μ². Var(X) = E(X²) − [E(X)]². Quoting E(X²) as the variance, or getting a negative variance, means a step is missing.
Var(aX + b) = aVar(X) + b. The b vanishes and the a is squared.
Integrating across a join. For a piecewise pdf, split every integral at the point where the rule changes, and use each rule only on its own interval.
Finding the median in the wrong piece. Compute the area of the first piece first; if it is less than 1/2, the median is in the second piece. Reject any root outside the domain.
Treating f(x) as a probability. f(x) can exceed 1, and P(X = a) = 0 for a continuous variable. Probabilities are areas.
10Work it right
- Write the property you are using as the first line: "∫ f(x) dx = 1", "E(X) = ∫ x f(x) dx", "Var(X) = E(X²) − [E(X)]²". It is the method mark.
- For a discrete variable, tabulate x, P(X = x), x P(X = x) and x² P(X = x), and sum the columns.
- Write the limits on every integral; on Paper 1 show the antiderivative in square brackets before substituting.
- For a piecewise pdf, split every integral at the join, and find the first piece's area before looking for the median.
- Mode: differentiate and justify the maximum, or read it from a sketch and say why. Median: solve ∫ f(x) dx up to m = 1/2 and reject roots outside the domain.
- Check: total probability 1, variance positive, mean inside the interval, and b never in a variance.
11Try it
Marks in brackets. Q1, Q2, Q4 and Q5 are Paper 1 style, no calculator. Q3 is Paper 2 style.
Q1. A discrete random variable X has P(X = x) = k(5 − x) for x ∈ {1, 2, 3, 4}.
(a) Find k. 2 marks
(b) Find E(X). 2 marks
(c) Find Var(X). 3 marks
(d) Hence find E(3X − 2) and Var(3X − 2). 2 marks
Q2. A continuous random variable X has pdf f(x) = k(9 − x²) for 0 ≤ x ≤ 3, and f(x) = 0 otherwise.
(a) Show that k = 1/18. 3 marks
(b) Find P(X < 1). 3 marks
(c) Write down the mode of X, giving a reason. 1 mark
(d) Find E(X). 3 marks
Q3. A continuous random variable X has pdf f(x) = kxe⁻ˣ for 0 ≤ x ≤ 3, and f(x) = 0 otherwise.
(a) Find the value of k. 2 marks
(b) Find the mode of X. 2 marks
(c) Find the median of X. 3 marks
(d) Find E(X) and Var(X). 4 marks
Q4. A continuous random variable X has pdf f(x) = kx for 0 ≤ x ≤ 1, f(x) = k(3 − x)/2 for 1 < x ≤ 3, and f(x) = 0 otherwise.
(a) Show that k = 2/3. 3 marks
(b) Write down the mode of X. 1 mark
(c) Show that the median of X is 3 − √3. 5 marks
Q5. In a game a player pays $c and rolls a fair six-sided die. The player receives $4 for a 6, $1 for a 4 or a 5, and nothing otherwise. Let G be the player's gain in dollars.
(a) Find the value of c for which the game is fair. 3 marks
(b) For this value of c, find Var(G). 3 marks
(c) The organiser doubles every prize and the entry fee. Write down the expected gain and the variance of the gain for the new game. 2 marks
12In one breath
A discrete random variable has a list of values with probabilities summing to 1; E(X) = Σ x P(X = x), E(X²) = Σ x² P(X = x), and Var(X) = E(X²) − [E(X)]², with the standard deviation its square root. A game is fair when the expected gain is 0. A continuous random variable has a pdf f(x) ≥ 0 whose total area is 1; probabilities are areas, single values have probability 0, and f(x) itself can exceed 1. Its mode is where f is greatest, its median m solves ∫ f(x) dx up to m = 1/2, its mean is ∫ x f(x) dx, and its variance is ∫ x² f(x) dx − μ². For a piecewise pdf, split every integral at the join and check which piece holds half the area. A long left tail puts mean < median < mode; a long right tail reverses it. Finally, E(aX + b) = aE(X) + b and Var(aX + b) = a²Var(X): adding shifts, multiplying stretches, and b never touches the variance.
Answers
Q1. (a) k(4 + 3 + 2 + 1) = 1, so 10k = 1 and k = 1/10. M1 for setting the sum of the probabilities equal to 1, A1 for 1/10.
(b) E(X) = (1 × 4 + 2 × 3 + 3 × 2 + 4 × 1)/10 = 20/10 = 2. M1 for Σ x P(X = x), A1 for 2.
(c) E(X²) = (1 × 4 + 4 × 3 + 9 × 2 + 16 × 1)/10 = 50/10 = 5, so Var(X) = 5 − 2² = 1. M1 for Σ x² P(X = x), A1 for E(X²) = 5, A1 for Var(X) = 1.
(d) E(3X − 2) = 3(2) − 2 = 4. Var(3X − 2) = 3² × 1 = 9. A1 for each. Var = 3 × 1 − 2 = 1 scores A0.
Q2. (a) ∫₀³ k(9 − x²) dx = k[9x − x³/3]₀³ = k(27 − 9) = 18k = 1, so k = 1/18. M1 for setting the integral equal to 1, A1 for the correct antiderivative, A1 for 18k = 1 leading to the given answer.
(b) P(X < 1) = (1/18)[9x − x³/3]₀¹ = (1/18)(9 − 1/3) = (1/18)(26/3) = 13/27. M1 for integrating f from 0 to 1, A1 for 26/3 (or equivalent), A1 for 13/27.
(c) The mode is 0, because f(x) = (9 − x²)/18 is decreasing on [0, 3], so its greatest value is at x = 0. A1 for 0 with a reason.
(d) E(X) = (1/18)∫₀³ (9x − x³) dx = (1/18)[9x²/2 − x⁴/4]₀³ = (1/18)(81/2 − 81/4) = (1/18)(81/4) = 9/8. M1 for ∫ x f(x) dx, A1 for the correct antiderivative, A1 for 9/8.
Q3. (a) Using the GDC, ∫₀³ xe⁻ˣ dx = 0.80085…, so k = 1 ÷ 0.80085… = 1.25 (3 s.f.; 1.24867…). M1 for setting k × ∫₀³ xe⁻ˣ dx = 1, A1 for 1.25.
(b) f′(x) = k(e⁻ˣ − xe⁻ˣ) = ke⁻ˣ(1 − x) = 0 when x = 1, and f′ changes from positive to negative there, so the mode is 1. (Or: the maximum of the graph on the GDC is at x = 1.) M1 for differentiating or using the graph's maximum, A1 for 1.
(c) Solve ∫₀ᵐ kxe⁻ˣ dx = 0.5 with the GDC: m = 1.38 (3 s.f.). M1 for the equation with the correct limits, A1 for a correct GDC set-up with their k, A1 for 1.38.
(d) E(X) = ∫₀³ kx²e⁻ˣ dx = 1.44 (3 s.f.). E(X²) = ∫₀³ kx³e⁻ˣ dx = 2.6429…, so Var(X) = 2.6429 − 1.44049² = 0.568 (3 s.f.). M1 for ∫ x f(x) dx, A1 for 1.44, M1 for ∫ x² f(x) dx − [E(X)², A1 for 0.568. Squaring the rounded 1.44 gives 0.569, also accepted.]
Q4. (a) ∫₀¹ kx dx + ∫₁³ k(3 − x)/2 dx = k/2 + (k/2)[3x − x²/2]₁³ = k/2 + (k/2)(9/2 − 5/2) = k/2 + k = 3k/2. Setting 3k/2 = 1 gives k = 2/3. M1 for splitting the integral at 1, A1 for k/2 and k, A1 for 3k/2 = 1 leading to the given value.
(b) The mode is 1, the peak where the rising piece meets the falling piece. A1.
(c) P(X ≤ 1) = k/2 = 1/3 < 1/2, so the median m is in the second piece. Then 1/3 + ∫₁ᵐ (3 − x)/3 dx = 1/2, so (1/3)[3x − x²/2]₁ᵐ = 1/6, giving 3m − m²/2 − 5/2 = 1/2, so m² − 6m + 6 = 0 and m = 3 ± √3. Since 1 < m ≤ 3, m = 3 − √3. R1 for showing the first piece has area 1/3 < 1/2, M1 for an equation for m using the second piece, A1 for a correct integrated equation, A1 for m² − 6m + 6 = 0, R1 for rejecting 3 + √3 with a reason.
Q5. (a) Let W be the amount received. E(W) = 4(1/6) + 1(2/6) + 0(3/6) = 6/6 = 1. The gain is G = W − c, so E(G) = 1 − c = 0 when c = 1. M1 for the expected amount received, A1 for E(W) = 1, A1 for c = 1.
(b) E(W²) = 16(1/6) + 1(2/6) = 18/6 = 3, so Var(W) = 3 − 1² = 2. Var(G) = Var(W − 1) = 2. M1 for E(W²), A1 for Var(W) = 2, A1 for Var(G) = 2 using Var(W − c) = Var(W).
(c) The new gain is 2W − 2 = 2G, so the expected gain is 2 × 0 = 0 and the variance is 2² × 2 = 8. A1 for 0, A1 for 8. A variance of 4 (doubling rather than squaring 2) scores A0.
Educerie · written from the published IB Diploma Programme Mathematics: analysis and approaches guide, first assessment 2021, section 4.14 Discrete and continuous random variables. Original text, examples and questions. Diagrams drawn by Educerie. Last reviewed 25 September 2026.