Skip to content
IB Diploma ProgrammeSL & HL

Continuous random variables

Mathematics: Analysis and Approaches SL & HL Chapter Notes

Last updated November 2026

ShareWhatsAppPost

Continuous random variables notes as a printable PDF.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Continuous random variables notes as text: skim, search, and jump between subtopics.

~15 min read

1. Variance of a discrete random variable

For a discrete random variable, first find E(X) as in SL 4.7. Then find E(X²) by squaring each value before multiplying by its probability.

The variance is Var(X) = E(X²) - [E(X)]². The standard deviation is the square root of the variance.

Write each sum out term by term so that the method mark is clear. Give an exact value or three significant figures.

E(X) = sum x P(X = x)

E(X²) = sum x² P(X = x)

Var(X) = E(X²) - [E(X)]²

Worked example 15 marks

The discrete random variable X has the following probability distribution. Find Var(X).

x0123
P(X = x)0.20.10.40.3
  1. 1

    attempt to use formula for expected value: E(X) = 0 × 0.2 + 1 × 0.1 + 2 × 0.4 + 3 × 0.3 (M1) [1]

  2. 2

    E(X) = 1.8 (A1) [1]

  3. 3

    attempt to find E(X²) by squaring each value: 0² × 0.2 + 1² × 0.1 + 2² × 0.4 + 3² × 0.3 (M1) [1]

  4. 4

    E(X²) = 0.1 + 1.6 + 2.7 = 4.4 (A1) [1]

  5. 5

    Var(X) = E(X²) - [E(X)]² = 4.4 - 1.8² = 1.16 (A1) [1]

2. Fair games

In a game, let X be the gain of a player. The gain is the winnings minus the stake the player pays to play.

The syllabus asks for the use of E(X) for "fair" games. As in SL 4.7, E(X) = 0 indicates a fair game.

To find an unknown stake, write E(X) in terms of the stake and set it equal to 0.

E(X) = 0 ⇒ fair game

gain = winnings - stake

Worked example 14 marks

A player pays s dollars to play a game. Two fair coins are tossed. The player receives 0 dollars for no heads, 2 dollars for one head and 6 dollars for two heads. Determine the value of s that makes the game fair.

  1. 1

    P(0 heads) = 1/4, P(1 head) = 1/2, P(2 heads) = 1/4. Expected winnings: 0 × 1/4 + 2 × 1/2 + 6 × 1/4 (M1) [1]

  2. 2

    expected winnings = 2.5 (A1) [1]

  3. 3

    gain is winnings minus stake, so E(X) = 2.5 - s (M1) [1]

  4. 4

    fair game, so E(X) = 0 and s = 2.5 dollars (A1) [1]

3. Probability density functions

A continuous random variable X has a probability density function f. Probabilities are areas under f: P(a ≤ X ≤b) = int_a^(b) f(x) dx.

The total area under f is 1, so int_-∞^(∞) f(x) dx = 1. This is the equation used to find an unknown constant in f.

A piecewise function has a different rule on each interval. Integrate each rule over its own interval and add. Outside the stated intervals f is zero. If the graph is a triangle, its area is 1/2 × base × height and that also equals 1.

int_-∞^(∞) f(x) dx = 1

P(a ≤ X ≤ b) = int_a^(b) f(x) dx

Worked example 12 marks

The continuous random variable X has a probability distribution f defined as f(x) = begincases b/ax, & 0 ≤ x ≤ a b/(a - 5)(x - 5), & a < x ≤ 5 endcases where 0 < a < 5 and b ∈ Q⁺.

The graph of f is shown in the following diagram.

(a) Show that b = 0.4.

  1. 1

    recognition that total area = 1: area of triangle = 1 or int₀⁵ f(x) dx = 1 (M1) [1]

  2. 2

    5b/2 = 1 (A1) [1]

  3. 3

    b = 0.4 (AG)

4. Mode and median of a continuous random variable

The mode is a value at which the probability density function has a maximum value. On the graph of f it is the position of the highest point.

The median m is the value that splits the area under f into two halves, so int_-∞^(m) f(x) dx = 1/2.

To compare the median with the mode, find the area to the left of the mode. If it is less than 1/2, the median lies to the right of the mode. Always give a reason, not only the word "greater".

int_-∞^(m) f(x) dx = 1/2

Worked example 14 marks

In a marathon race, the random variable T represents the time, in hours, taken for a runner to complete the race. No runner completes the race in less than 2.25 hours, and no runner completes it in more than 7.5 hours.

The probability density function for T is modelled by f, defined by f(t) = begincases 4/21(1 - cos(4π/9(t - 2.25))), & 2.25 ≤ t < 4.5 4/21(1 + cos(π/3(t - 4.5))), & 4.5 ≤ t ≤ 7.5 0, & otherwise. endcases

The graph of f has a maximum point at t = 4.5 as shown in the following diagram:

(a)(i) Find the value of int_2.25^(4.5) f(t) dt.

(ii) Write down the mode of T.

(iii) Determine which is greater, the mode of T or the median of T, justifying your answer.

  1. 1

    (i) int_2.25^(4.5) f(t) dt = 3/7 (= 0.429) (A1) [1]

  2. 2

    (ii) mode of T = 4.5 (A1) [1]

  3. 3

    (iii) the median is greater (A1) [1]

  4. 4

    P(T < 4.5) < 0.5 or P(T > 4.5) > 0.5 or median = 4.69 (R1). Accept reference to areas rather than probabilities. [1]

5. Mean and variance: continuous variables

For a continuous random variable the sums become integrals. E(X) is the integral of x f(x) and E(X²) is the integral of x² f(x).

For a piecewise f, apply the formula to all pieces: integrate each piece over its own interval and add the results.

The variance formula is the same as for a discrete variable: Var(X) = E(X²) - [E(X)]². The standard deviation is its square root. When an unknown constant is in the integral, equate to the given mean and solve.

E(X) = int_-∞^(∞) x f(x) dx

E(X²) = int_-∞^(∞) x² f(x) dx

Var(X) = E(X²) - [E(X)]²

Worked example 14 marks

The continuous random variable X has a probability distribution f defined as f(x) = begincases b/ax, & 0 ≤ x ≤ a b/(a - 5)(x - 5), & a < x ≤ 5 endcases where 0 < a < 5 and b ∈ Q⁺.

The graph of f is shown in the following diagram. It is given that b = 0.4 and E(X) = 3.2.

(b) Find the value of a.

  1. 1

    attempt to apply formula for E(X) to all pieces of the function (M1) [1]

  2. 2

    E(X) = int₀^(a) x · 0.4/ax dx + int_a⁵ x · 0.4/(a - 5)(x - 5) dx (A1) [1]

  3. 3

    attempt to substitute limits, subtract in the correct order and equate to 3.2 (M1) [1]

  4. 4

    a = 4.6 (A1) [1]

6. Linear transformations of a random variable

If X is a random variable and a and b are constants, the variable aX + b has a mean and variance given by the formulas below. They hold for discrete and continuous variables.

Adding b moves the mean by b but does not change the spread. Multiplying by a scales the mean by a and the variance by a². Because of the square, Var(aX +b) is never negative, even when a is negative.

For a linear transformation, attempt to find the variance with a², not a. To get a standard deviation from a variance, take the square root last. Keep unrounded values until the final line.

E(aX + b) = a E(X) + b

Var(aX + b) = a² Var(X)

Worked example 17 marks

In a marathon race, the random variable T represents the time, in hours, taken for a runner to complete the race. No runner completes the race in less than 2.25 hours, and no runner completes it in more than 7.5 hours.

Each runner's time is converted to a score which is calculated as a - bt, where t represents their time in hours, and a, b > 0.

Consider the random variable P which represents the score of a runner. It is given that E(P) = 100 and the maximum possible score is 150.

(e) Use E(T) = 4.723 to determine the value of a and the value of b, giving your answers to the nearest integer.

(f) Given also that Var(T) = 0.906, find Var(P).

  1. 1

    (e) attempt to find the expected value for a transformed linear variable: E(P) = E(a - bT) = a - b E(T) (M1) [1]

  2. 2

    a - 4.723b = 100 (A1) [1]

  3. 3

    recognition that max score is achieved with fastest time t = 2.25 (M1) [1]

  4. 4

    a - 2.25b = 150 (A1) [1]

  5. 5

    a = 195.491…, b = 20.2183…, so a = 195, b = 20 (A1). These must be given to the nearest integer. [1]

  6. 6

    (f) attempt to find variance for a transformed linear variable: Var(P) = Var(a - bT) = b² Var(T) (M1) [1]

  7. 7

    0.906 × (20.2183…)² = 370.356…, so Var(P) = 370 (A1). Accept any answer from 362 to 370 inclusive, from less accurate values of b. [1]

Recap

  • Var(X) = E(X²) - [E(X)]², with E(X²) = sum x² P(X = x). Standard deviation is the square root.
  • A game with gain X (winnings minus stake) is fair when E(X) = 0.
  • A probability density function has total area 1: int_-∞^(∞) f(x) dx = 1. Probability is area.
  • Mode: where f is greatest. Median m: int_-∞^(m) f(x) dx = 1/2.
  • Continuous E(X) = int x f(x) dx and E(X²) = int x² f(x) dx, over every piece.
  • E(aX + b) = a E(X) + b and Var(aX + b) = a² Var(X).
  • Show the method. A correct answer with no working may earn no marks.

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. Do not use a calculator. State the value of E(X) when X is the gain in a fair game.1 mark
    Answer
    1. E(X) = 0 (A1)

    Trap: The gain is winnings minus stake. It is the gain, not the winnings, that has an expected value of 0.

  2. The discrete random variable X has P(X = 1) = 0.5, P(X = 2) = 0.3 and P(X = 4) = 0.2. Find Var(X).3 marks
    Answer
    1. E(X) = 1 × 0.5 + 2 × 0.3 + 4 × 0.2 = 1.9 (A1)
    2. E(X²) = 1 × 0.5 + 4 × 0.3 + 16 × 0.2 = 4.9 (A1)
    3. Var(X) = 4.9 - 1.9² = 1.29 (A1)

    Trap: Subtracting E(X) instead of [E(X)]² gives 4.9 - 1.9 = 3.0.

  3. The random variable X has mean 6 and variance 4. The random variable Y is given by Y = 3 - 2X. Calculate E(Y) and the standard deviation of Y.4 marks
    Answer
    1. E(Y) = 3 - 2 × 6 (M1)
    2. E(Y) = -9 (A1)
    3. Var(Y) = (-2)² × 4 = 16 (M1)
    4. standard deviation of Y = √16 = 4 (A1)

    Trap: Using -2 instead of (-2)² gives a variance of -8, and the constant 3 does not change the spread.

  4. Do not use a calculator. The continuous random variable X has probability density function f(x) = kx for 0 ≤ x ≤ 4, and f(x) = 0 otherwise. Find the value of k, and hence find P(X < 2).4 marks
    Answer
    1. total area is 1: int₀⁴ kx dx = 1 (M1)
    2. 8k = 1, so k = 1/8 (A1)
    3. P(X < 2) = int₀² x/8 dx (M1)
    4. = [x²/16]₀² = 1/4 (A1)

    Trap: Setting f(4) = 1 gives k = 1/4. A density is not a probability: the area must be 1.

  5. Do not use a calculator. The continuous random variable X has probability density function f(x) = x/2 for 0 ≤ x ≤ 2, and f(x) = 0 otherwise. State the mode of X and find the median of X.4 marks
    Answer
    1. f increases as x increases, so its maximum is at x = 2: mode = 2 (A1)
    2. median m: int₀^(m) x/2 dx = 1/2 (M1)
    3. m²/4 = 1/2, so m² = 2 (A1)
    4. m = √2, as m must lie between 0 and 2 (A1)

    Trap: The median is not the midpoint of the interval. Taking m = 1 ignores that more area lies near x = 2.

  6. Do not use a calculator. The continuous random variable X has probability density function f(x) = 3x²/8 for 0 ≤ x ≤ 2, and f(x) = 0 otherwise. Find E(X) and Var(X).5 marks
    Answer
    1. E(X) = int₀² x · 3x²/8 dx = 3/8[x⁴/4]₀² (M1)
    2. E(X) = 3/8 × 4 = 3/2 (A1)
    3. E(X²) = int₀² x² · 3x²/8 dx = 3/8[x⁵/5]₀² = 12/5 (M1)(A1)
    4. Var(X) = 12/5 - (3/2)² = 3/20 (A1)

    Trap: Integrating f(x) instead of x f(x) gives the total area, 1, not the mean.

  7. Do not use a calculator. The continuous random variable X has probability density function f(x) = begincases cx, & 0 ≤ x < 2 c(6 - 2x), & 2 ≤ x ≤ 3 0, & otherwise. endcases Find the value of c, and hence find E(X).5 marks
    Answer
    1. total area is 1: int₀² cx dx + int₂³ c(6 - 2x) dx = 1 (M1)
    2. 2c + c = 1, so c = 1/3 (A1)
    3. apply the formula to both pieces: E(X) = int₀² x²/3 dx + int₂³ (x(6 - 2x))/3 dx (M1)
    4. = 8/9 + 7/9 (A1)
    5. E(X) = 5/3 (A1)

    Trap: Integrating only one rule over 0 to 3 misses the change of rule at x = 2. Each piece has its own limits.

  8. A delivery company's cost, in dollars, for one delivery is C = 3 + 0.4D, where D is the distance in kilometres. The distance has mean 12.5 km and standard deviation 4 km. Calculate E(C) and Var(C).4 marks
    Answer
    1. E(C) = 3 + 0.4 × 12.5 (M1)
    2. E(C) = 8 dollars (A1)
    3. Var(D) = 4² = 16 (M1)
    4. Var(C) = 0.4² × 16 = 2.56 (A1)

    Trap: The 4 is a standard deviation. Using it as the variance gives 0.16 × 4 = 0.64. Using 0.4 × 16 gives 6.4.

  9. A player pays 5 dollars to play a game. A fair six-sided die is rolled once. A score of 6 wins k dollars, a score of 4 or 5 wins 5 dollars, and any other score wins nothing. The gain of the player is X dollars. (a) Find the value of k for which the game is fair. (b) For this value of k, calculate the standard deviation of X. (c) The organiser doubles the stake and every prize. Write down the expected gain of a player, and find the standard deviation of the new gain.8 marks
    Answer
    1. (a) the gains are k - 5, 0 and -5 with probabilities 1/6, 2/6 and 3/6 (M1)
    2. E(X) = (k - 5)/6 + 0 - 15/6 = 0 (M1)
    3. k = 20 (A1)
    4. (b) E(X²) = 15² × 1/6 + 0² × 2/6 + (-5)² × 3/6 (M1)
    5. E(X²) = 50 (A1)
    6. Var(X) = 50 - 0² = 50, so the standard deviation is √50 = 7.07 dollars (A1)
    7. (c) the new gain is 2X: E(2X) = 2 × 0 = 0 (A1)
    8. Var(2X) = 2² × 50 = 200, standard deviation = √(200) = 14.1 dollars (A1)

    Trap: Every outcome costs the stake, not only the winning one, so the gains are k - 5, 0 and -5; in (c) doubling multiplies the variance by 4 but the standard deviation by 2.

  10. A machine part lasts T years, where T has probability density function f(t) = kt²(4 - t) for 0 ≤ t ≤ 4, and f(t) = 0 otherwise. (a) Show that k = 3/64. (b) Determine which is greater, the mode of T or the median of T, justifying your answer. The value of the part, in dollars, after T years is V = 500 - 80T. (c) Calculate E(V) and the standard deviation of V.13 marks
    Answer
    1. (a) total area is 1: int₀⁴ kt²(4 - t) dt = 1 (M1)
    2. k[4t³/3 - t⁴/4]₀⁴ = 64k/3 = 1 (A1), so k = 3/64 (AG)
    3. (b) f'(t) = 3/64(8t - 3t²) = 0 (M1), and f(0) = f(4) = 0, so the mode is 8/3 = 2.67 years (A1)
    4. the mode is greater (A1), because int₀^(8/3) f(t) dt = 16/27 = 0.593 > 0.5 (M1)(R1)
    5. (c) E(T) = int₀⁴ t f(t) dt = 2.4 (M1)(A1), so E(V) = 500 - 80 × 2.4 = 308 dollars (A1)
    6. Var(T) = int₀⁴ t² f(t) dt - 2.4² = 6.4 - 5.76 = 0.64 (M1)(A1)
    7. Var(V) = (-80)² × 0.64 = 4096, so the standard deviation is 64 dollars (A1)

    Trap: Decide by area, not by shape: here P(T < 8/3) = 16/27 > 1/2, so, unlike the marathon, the mode is greater. A standard deviation uses (-80)², so it is 64, not -64.

Say this, not that

Wording that loses the mark, against the wording the mark scheme credits.

Loses the markGets the mark
Var(a - bT) = b Var(T), or -b Var(T)attempt to find variance for a transformed linear variable: Var(a - bT) = b² Var(T)
the median is greater because the graph is skewedthe median is greater because P(T < 4.5) < 0.5: reference to areas is accepted
E(X) = int f(x) dx, or one integral over the whole intervalapply formula for E(X) to all pieces: int x f(x) dx for each piece
a = 195.491…, b = 20.2183… as the final answera = 195, b = 20: nearest integer, as the question asks

Frequently asked questions

How do I find the variance of a discrete random variable?
Find E(X²) by squaring each value before multiplying by its probability. Then Var(X) = E(X²) - [E(X)]². The standard deviation is the square root of the variance. Write each sum out term by term so that the method mark is clear.
How do the mean and variance change when I transform a random variable to aX + b?
E(aX + b) = a E(X) + b and Var(aX + b) = a² Var(X). Adding b moves the mean but does not change the spread, and multiplying by a scales the variance by a². Because of the square, the variance is never negative, even when a is negative. Take the square root last.
How do I find the constant in a probability density function?
The total area under f is 1, so int_-∞^(∞) f(x) dx = 1. Use this equation to find the unknown constant. For a piecewise function, integrate each rule over its own interval and add the results. If the graph is a triangle, its area is 1/2 × base × height, and that also equals 1.
How do I find the median of a continuous random variable?
The median m satisfies int_-∞^(m) f(x) dx = 1/2, so it splits the area under f into two halves. To compare the median with the mode, find the area to the left of the mode. If that area is less than 1/2, the median lies to the right of the mode. Always give a reason, not only the word greater.
How do I find E(X) and Var(X) for a continuous random variable?
Replace the sums by integrals: E(X) = int x f(x) dx and E(X²) = int x² f(x) dx. For a piecewise f, apply the formula to all pieces, integrating each over its own interval. Then use Var(X) = E(X²) - [E(X)]².
Why is integrating f(x) wrong when I want the mean of a continuous random variable?
Integrating f(x) over all x gives the total area, which is 1, not the mean. The mean needs int x f(x) dx. A density is also not a probability: the area under f must be 1, so a value of f(4) = 1 does not give k.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters