MathematicsCore22 min read

Continuous Random Variables

When the sum becomes an integral

This topic appears in:

01

From a list of probabilities to a curve

A discrete variable has a list: each value carries its own probability, and the list adds to 1. A continuous variable cannot work that way, because between any two values there is another — the list would be infinite and every entry would have to be zero.

Instead, probability is carried by a probability density function, written f(x). The density itself is not a probability. What is a probability is the area under the curve between two values, which is why every rule from the discrete case reappears with the sum replaced by an integral.

total probability:∫ f(x) dx = 1over the whole rangeP(a < X < b) = ∫ₐᵇ f(x) dxf(x) ⩾ 0 everywhereP(X = a) = 0— a single point has no widththe sum of the discrete case becomes an integral
f(x)
the probability densitya height, not a probability — it may exceed 1
∫f dx = 1
the total areathe continuous version of ΣP = 1
P(X = a)
always zeroso < and ⩽ give the same answer

Density is not probability

f(x) can be greater than 1 without anything being wrong. A distribution spread over the interval from 0 to 0.5 must have an average height of 2 for its area to come to 1. What can never exceed 1 is the area. Confusing the height with the probability is the conceptual error that makes the rest of the topic feel arbitrary.

02

Every formula, translated

Once the sum has become an integral, nothing else changes. Each discrete formula has a continuous twin that looks almost identical, and knowing the pairing means there is very little new to learn.

DiscreteContinuousWhat it gives
Σ P(X = x) = 1∫ f(x) dx = 1total probability
Σ x·P(X = x)∫ x·f(x) dxthe mean, E(X)
Σ x²·P(X = x)∫ x²·f(x) dxE(X²)
E(X²) − μ²E(X²) − μ²the variance — unchanged
running totalF(x) = ∫₋∞ˣ f(t) dtthe cumulative distribution
E(X) = ∫ x·f(x) dxE(X²) = ∫ x²·f(x) dxVar(X) = E(X²) − [E(X)]²F(x) = ∫ f dtandf(x) = dF/dxF and f are related by calculus: integrate one, differentiate the other
F(x)
the cumulative functionF(x) = P(X ⩽ x), rising from 0 to 1
dF/dx
recovering the densitydifferentiate the cumulative function
median m
solves F(m) = 0.5the value with half the area on each side
Worked example

The random variable X has f(x) = kx² for 0 ⩽ x ⩽ 3, and f(x) = 0 otherwise. Find k, E(X), and the median.

  1. Total area is 1: ∫₀³ kx² dx = k[x³/3]₀³ = 9k = 1, so k = 1/9.Always the first step — the density must integrate to 1 over its range.
  2. E(X) = ∫₀³ x·(x²/9) dx = (1/9)∫₀³ x³ dx = (1/9)[x⁴/4]₀³.Multiply the density by x, then integrate over the same range.
  3. = (1/9)(81/4) = 2.25.The mean sits well right of centre, as expected for a density that grows with x.
  4. For the median m: ∫₀ᵐ (x²/9) dx = 0.5, so m³/27 = 0.5.The median splits the area in half, so the integral up to m equals 0.5.
  5. m³ = 13.5, so m = 2.38.Below the mean, which is the expected order for a right-skewed distribution.

k = 1/9, E(X) = 2.25, median = 2.38

03

The cumulative distribution function

F(x) answers "what is the probability of being at most x". It starts at 0 below the range, climbs to 1 above it, and never decreases — because accumulating more area can only add.

It is often quicker than integrating from scratch. Once F is known, P(a < X < b) = F(b) − F(a), exactly as with the normal tables. And since integrating gives F, differentiating gives f back — a fact questions exploit in both directions.

Use the limits the density actually occupies

If f is defined only on [0, 3], then integrating from 0 to 5 is wrong — beyond 3 the density is zero and contributes nothing, but writing the wrong limits usually produces a wrong answer rather than a harmless one. For P(X > 2) with that density, integrate from 2 to 3, not from 2 to infinity.

What to do when

  1. Find an unknown constant → set the total integral to 1.
  2. Find a probability over an interval → integrate f between the limits, or use F(b) − F(a).
  3. Find the mean → integrate x·f(x).
  4. Find the variance → integrate x²·f(x), then subtract μ².
  5. Find the median → solve F(m) = 0.5.
  6. Given F and asked for f → differentiate. Given f and asked for F → integrate.
  7. Piecewise densities must be integrated piece by piece, over the correct limits for each.
04

The uniform distribution

One continuous distribution appears often enough to be worth knowing outright: the rectangular or uniform distribution, where every value in an interval is equally likely and the density is a horizontal line.

Its height follows from the total area being 1. Over an interval from a to b the width is b − a, so the height must be 1/(b − a) for the rectangle to have area 1. Everything else can be read off geometry rather than calculus — the mean is the midpoint by symmetry, and a probability is just the fraction of the interval covered.

X ~ U(a, b)f(x) = 1 / (b − a)for a ⩽ x ⩽ b, 0 elsewhereE(X) = (a + b) / 2the midpoint, by symmetryVar(X) = (b − a)² / 12P(c < X < d) = (d − c) / (b − a)probabilities are fractions of the interval — no integration needed
1/(b − a)
the densitywhatever height makes the area 1
(a + b)/2
the meanthe midpoint, since the shape is symmetric
(b − a)²/12
the variancea standard result worth memorising

A useful check on any density

Before doing anything else, confirm the total area is 1. For a rectangle that is height × width; for a triangle it is ½ × base × height. If the area is not 1 the density is wrong, and every probability, mean and variance computed from it will be wrong too — so it is worth thirty seconds at the start rather than discovering it at the end.

05

Piecewise densities

A density is often defined in pieces — one expression on one interval and a different one on the next. Nothing changes conceptually, but every calculation has to be split at the boundary and the parts added.

The total-area condition becomes a sum of integrals, one per piece, set equal to 1. A probability spanning the boundary likewise splits into the part in each piece. The commonest error is integrating a single expression across the whole range as though the other piece did not exist.

∫ over piece 1 + ∫ over piece 2 = 1P(a < X < b) spanning a boundary at m:∫ from a to m using the first expression+ ∫ from m to b using the secondsplit at every boundary the interval crosses, then add
boundary
where the definition changesalways a limit of integration
each piece
its own expressionnever integrate one across the other

Sketch it before integrating

A quick sketch of a piecewise density shows the shape, makes the boundary obvious, and often reveals that part of the area is a triangle or rectangle whose area can simply be written down. Several exam densities are made entirely of straight lines, and geometry is both faster and less error-prone than integration there.

Practice questions

5 questions · 18 marks · full working on every one

Try each one on paper first, then open the working. The marks are shown where they are actually awarded, because that is where they are actually lost.

Short questions

2 · 4 marks

Two marks each, in the style of the short-question section of the paper. Answer in two or three lines.

SQ1[2 marks]
Explain why a probability density function may take values greater than 1, while a probability may not.
Model answer

f(x) is a density — a height, not a probability. Probability is the area under the curve, and a tall narrow curve can enclose an area of 1 while having heights above 1. Only the area is constrained to lie between 0 and 1.

Examiner tip. The distinction between height and area is the mark. An example such as a density on [0, 0.5] makes it concrete.

SQ2[2 marks]
A cumulative distribution function is given by F(x) = x²/16 for 0 ⩽ x ⩽ 4. Find the probability density function.
Model answer

Differentiate: f(x) = dF/dx = 2x/16 = x/8 for 0 ⩽ x ⩽ 4, and zero elsewhere.

Examiner tip. F and f are linked by calculus. Integrating f gives F, so differentiating F gives f back — and the range must be stated with it.

Solved numericals

2 · 8 marks

Full working, one step per line, with the marks shown where they are awarded.

N1[4 marks]
X has probability density function f(x) = k(4 − x) for 0 ⩽ x ⩽ 4, and 0 otherwise. Find k and E(X).
Full working
  1. ∫₀⁴ k(4 − x) dx = k[4x − x²/2]₀⁴ = k(16 − 8) = 8kSetting up the total-area integral.[1]
  2. 8k = 1, so k = 1/8The density must integrate to 1.[1]
  3. E(X) = ∫₀⁴ x·(4 − x)/8 dx = (1/8)[2x² − x³/3]₀⁴ = (1/8)(32 − 64/3)Multiplying by x before integrating.[1]
  4. = (1/8)(32/3) = 4/3 = 1.33Left of centre, as expected for a density that decreases with x.[1]

k = 1/8, E(X) = 4/3

N2[4 marks]
X has f(x) = 3x²/8 for 0 ⩽ x ⩽ 2. Find the cumulative distribution function F(x) for 0 ⩽ x ⩽ 2, and hence the median.
Full working
  1. F(x) = ∫₀ˣ 3t²/8 dt = [t³/8]₀ˣIntegrating the density from the lower end of the range.[1]
  2. F(x) = x³/8 for 0 ⩽ x ⩽ 2Check: F(2) = 1 as required, which confirms the constant is right.[1]
  3. Median m satisfies m³/8 = 0.5, so m³ = 4The median splits the area into two halves.[1]
  4. m = ∛4 = 1.59Within the range [0, 2], which is a useful sanity check.[1]

F(x) = x³/8; median = 1.59

Exam questions

1 · 6 marks

Multi-part questions with a full mark scheme.

Q1[6 marks]
The lifetime X hours of a component has f(x) = x/50 for 0 ⩽ x ⩽ 10, and 0 otherwise.
(a) Verify that f is a valid probability density function.
(b) Find P(X > 6).
(c) Find E(X) and Var(X).
Mark scheme
  1. (a) f(x) ⩾ 0 on the range, and ∫₀¹⁰ x/50 dx = [x²/100]₀¹⁰ = 1Both conditions must be checked: non-negative, and total area 1.[1]
  2. (b) P(X > 6) = ∫₆¹⁰ x/50 dx = [x²/100]₆¹⁰ = 1 − 0.36 = 0.64Integrating to 10, the top of the range — not to infinity.[1]
  3. (c) E(X) = ∫₀¹⁰ x²/50 dx = [x³/150]₀¹⁰ = 1000/150Multiplying the density by x.[1]
  4. E(X) = 6.67 hoursRight of centre, matching a density that increases with x.[1]
  5. E(X²) = ∫₀¹⁰ x³/50 dx = [x⁴/200]₀¹⁰ = 50Multiplying by x² this time.[1]
  6. Var(X) = 50 − (6.67)² = 50 − 44.44 = 5.56Positive, as any variance must be.[1]

(a) verified; (b) 0.64; (c) E(X) = 6.67, Var(X) = 5.56