James Ashton MathsFREE MATHEMATICS. OPEN TO EVERYONE.
HomeIB DiplomaA levelAbout
IB Diploma › Maths AA HL › Topic 4: Statistics & probability › Continuous random variables

Continuous random variables

Random variables that can take any value in an interval, described by a probability density function. Probabilities as areas, and the mean, variance, median and mode found by integration.

AHL 4.14HL onlyPaper 1Paper 2≈ 90 min to work through
Before you start: discrete random variables and definite integration. See Discrete random variables and Integration and areas.

1What you need to know

Tick these off as you go. By the end of the page you should be able to do all of them without notes.

  • Explain what a probability density function (pdf) is, and why P(X=a)=0AHL 4.14
  • Use ∫f(x)dx=1 to find an unknown constantAHL 4.14
  • Find probabilities as areas under the pdfAHL 4.14
  • Find the mode, the median and the mean of a continuous random variableAHL 4.14
  • Find the variance, and use E(aX+b) and Var(aX+b)AHL 4.14
  • Work with piecewise pdfsAHL 4.14

2Notes & worked examples

Each idea is followed by a worked example. Try the question yourself first, then reveal the solution one step at a time.

The big idea

A discrete random variable lists its values and their probabilities, and ∑P(X=x)=1. A continuous random variable, such as a time or a length, can take any value in an interval, so it cannot list them. Instead it has a probability density function f: probabilities are areas under the graph of f. Every formula from discrete random variables carries over, with ∑ replaced by ∫.

2.1 The probability density function

A function f is a pdf on an interval [a,b] if two things are true:

Conditions for a pdf Not in booklet: learn it
f(x)≥0  for all xand∫abf(x)dx=1

Then P(c≤X≤d)=∫cdf(x)dx, and f(x)=0 outside [a,b].

Because a single point has no width, P(X=c)=0 for every c. So for a continuous random variable P(X<c) and P(X≤c) are the same. Note also that f(x) itself is not a probability, and can be bigger than 1: only areas are probabilities.

Worked example 1Paper 1
The random variable X has pdf f(x)=kx(4−x) for 0≤x≤4, and f(x)=0 otherwise. Find k, and find P(X<1).
∫04k(4x−x2)dx=k[2x2−x33]04=k(32−643)=32k3
Expand before integrating.
32k3=1⇒k=332
P(X<1)=332[2x2−x33]01=332·53=532

2.2 Mode and median

The mode is the value of x where f(x) is greatest. Find it as you would any maximum: solve f′(x)=0, but also check the endpoints, because the maximum is often at the end of the interval.

The median m splits the area in half:

Median Not in booklet: learn it
∫amf(x)dx=12
Worked example 2Paper 1
For the pdf in WE1, find the mode of X.
f(x)=332(4x−x2), so f′(x)=332(4−2x)
f′(x)=0⇒x=2. The mode is 2.
The graph is a symmetric "hill" on [0,4], so the median is 2 as well.
Worked example 3Paper 2
X has pdf f(x)=x29 for 0≤x≤3. Find the median and the mode.
∫0mx29dx=m327=12
m3=13.5⇒m=13.53=2.38 (3 s.f.)
f is increasing on [0,3], so the mode is at the endpoint: x=3.
Solving f′(x)=0 gives x=0, which is the minimum. Always check the endpoints.

2.3 Mean and variance

Mean and variance In formula booklet
E(X)=μ=∫xf(x)dxVar(X)=∫(x−μ)2f(x)dx=∫x2f(x)dx−μ2

The second form of the variance is almost always easier: find E(X2)=∫x2f(x)dx, then subtract the square of the mean. This is the same "mean of the squares minus the square of the mean" as for discrete variables.

Worked example 4Paper 1
For the pdf f(x)=332x(4−x), 0≤x≤4, find E(X) and Var(X).
E(X)=332∫04(4x2−x3)dx=332(2563−64)=332·643=2
E(X2)=332∫04(4x3−x4)dx=332(256−10245)=332·2565=245
Var(X)=245−22=45
So the standard deviation is about 0.894.
Worked example 5Paper 2
For f(x)=x29, 0≤x≤3, find E(X).
E(X)=∫03x39dx=8136=94=2.25
Mean 2.25 < median 2.38 < mode 3.
For a distribution skewed with a long tail to the left, the mean is pulled furthest from the peak.

2.4 Linear transformations

If Y=aX+b, every value is stretched by a and shifted by b. The shift moves the mean but does not change the spread.

Linear transformations In formula booklet
E(aX+b)=aE(X)+bVar(aX+b)=a2Var(X)
Worked example 6 (faded)Paper 1
For the variable in WE4, find E(5−3X) and Var(5−3X).
E(5−3X)=5−3(2)= −1  ← you work this out
Var(5−3X)=(−3)2×0.8= 7.2. The variance is never negative: a is squared.  ← you work this out

2.5 Piecewise pdfs

Some pdfs are defined by different formulas on different parts of the interval. Split every integral at the joins and add the pieces.

Worked example 7Paper 1
X has pdf f(x)=x4 for 0≤x≤2, f(x)=4−x4 for 2<x≤4. Show that f is a pdf, and find P(X<1) and P(1<X<3).
Total area: two triangles, each 12×2×12=12. Total =1, and f≥0.
Use geometry when the pdf is made of straight lines.
P(X<1)=∫01x4dx=18
By symmetry P(X>3)=18, so P(1<X<3)=1−18−18=34.
The graph is symmetric about x=2, so the mean and median are both 2.
Discrete and continuous side by side
DiscreteContinuous
Total probability∑P(X=x)=1∫f(x)dx=1
Mean∑xP(X=x)∫xf(x)dx
E(X2)∑x2P(X=x)∫x2f(x)dx
Modemost likely valuewhere f is greatest
P(X=c)can be positivealways 0
On your TI-Nspire Calculator tricks →

On Paper 2, integrate numerically: menu → Calculus → Numerical integral, e.g. ∫03x·x29dx. For a median, use nSolve on ∫0mf(x)dx=0.5 with m as the variable, or graph y=∫0xf(t)dt and intersect with y=0.5. For the mode, use Analyze Graph → Maximum, and remember to compare with the endpoints.

3Explore it

Choose a pdf and drag the endpoints: the shaded area is P(c<X<d). The dashed lines mark the mean (navy) and the median (green).

4Common mistakes & exam tips

Common mistakes

  • Treating f(x) as a probability. Only areas under f are probabilities.
  • Finding the mode with f′(x)=0 only, and missing a maximum at an endpoint.
  • Forgetting to subtract μ2 when finding the variance from E(X2).
  • Writing Var(aX+b)=aVar(X)+b. The b disappears and a is squared.
  • For a piecewise pdf, integrating one formula over the whole interval instead of splitting at the join.

Exam tips

  • Always find any unknown constant first: every later part depends on it.
  • On Paper 1 expand brackets before integrating; on Paper 2 integrate numerically and keep full accuracy.
  • A quick sketch of the pdf tells you where the mode is, roughly where the median is, and whether the mean is left or right of it.
  • For a median on Paper 2, set up ∫amf(x)dx=0.5 clearly before solving with the GDC: the equation earns the method mark.

5Practice

Fluency questions build the basics. Problem-solving questions make you think about which method to use.

FluencyP1
f(x)=kx for 0≤x≤2. Find k.
∫02kxdx=2k=1⇒k=12
FluencyP2
f(x)=14(x+1) for 0≤x≤2. Find E(X).
14∫02(x2+x)dx=14(83+2)=76
FluencyP3
f(x)=2x for 0≤x≤1. Find Var(X).
E(X)=23, E(X2)=12, so Var(X)=12−49=118
FluencyP4
f(x)=3x28 for 0≤x≤2. Find the median.
m38=12⇒m=43≈1.59
Problem solvingP5
E(X)=3 and Var(X)=2. Find E(5−2X) and Var(5−2X).
−1 and 8
Problem solvingP6
f(x)=ksinx for 0≤x≤π. Find k and P(X<π3).
∫0πksinxdx=2k=1⇒k=12. P=12(1−cosπ3)=14.

6Exam-style questions

Original questions in the style of the IB exam, with full markschemes. Give yourself about 1 minute per mark.

Question 1Paper 1[12 marks]

A continuous random variable X has probability density function f(x)=k(9−x2) for 0≤x≤3, and f(x)=0 otherwise.

  • (a)Show that k=118.[2]
  • (b)Find P(X<1).[2]
  • (c)Find E(X).[3]
  • (d)Show that Var(X)=171320.[3]
  • (e)Find E(4X−1).[2]
(a)
k∫03(9−x2)dx=1M1
k[9x−x33]03=18k=1A1
k=118AG
(b)
118[9x−x33]01M1
1327A1
(c)
118∫03(9x−x3)dxM1
118(812−814)A1
98A1
(d)
E(X2)=118∫03(9x2−x4)dx=95M1A1
95−(98)2=171320A1AG
(e)
4×98−1M1
72A1
Question 2Paper 2[4 marks]

For the random variable in the previous question, with f(x)=118(9−x2), 0≤x≤3:

  • (a)Find the median of X.[3]
  • (b)Write down the mode of X.[1]
(a)
118∫0m(9−x2)dx=0.5M1
m3−27m+27=0 or GDC(M1)
m=1.04A1
(b)
0 (since f is decreasing on [0,3])A1
Question 3Paper 2[9 marks]

The time, T hours, that a machine runs before it needs a reset is modelled by the probability density function f(t)=kte−t for 0≤t≤3, and f(t)=0 otherwise.

  • (a)Find the value of k.[2]
  • (b)Find the mode of T.[2]
  • (c)Find E(T).[2]
  • (d)Find the median of T.[2]
  • (e)Find P(T>2).[1]
(a)
k∫03te−tdt=1M1
k=1.25 (1.24867…)A1
(b)
f′(t)=k(1−t)e−t=0 or GDC maximumM1
t=1A1
(c)
k∫03t2e−tdtM1
1.44A1
(d)
k∫0mte−tdt=0.5M1
m=1.38A1
(e)
0.258A1

7Check yourself

Six quick questions, marked instantly. Aim for 6/6 before moving on. Fractions like 3/2 are accepted.

8Past-paper practice

Once you're scoring well above, try real IB questions. Your school or teacher will have these papers.

PaperQuestionFocusDifficulty
May 2022 · TZ1 · Paper 1Q7Finding k for a pdf involving k4−3x2, then a probability★★★
May 2023 · TZ2 · Paper 1Q6A constant pdf on [a,3a]: mean and variance in terms of a★★
May 2024 · TZ1 · Paper 2Q8A piecewise pdf with an unknown constant★★
Nov 2021 · Paper 2Q7Median, and P(|X−m|≤a)=0.3★★★
Nov 2025 · TZ1 · Paper 2Q11Finding P(μ−σ<X<μ+σ)★★★
Spotted a mistake on this page?Tell me and I'll fix it. The button opens an email with this page already named, or write to jamesashtonmaths@gmail.com.
Report a mistake