4.14 Discrete and continuous random variables

4.14 Discrete and continuous random variables

IB Maths: Analysis and Approaches HL: Revision notes

Studying this course? Keep your progress in one place.

Key facts

  • Discrete: E(X)=∑xP(X=x)E(X)=\sum xP(X=x), Var(X)=E(X2)−[E(X)]2\text{Var}(X)=E(X^2)-[E(X)]^2.
  • E(aX+b)=aE(X)+bE(aX+b)=aE(X)+b and Var(aX+b)=a2Var(X)\text{Var}(aX+b)=a^2\text{Var}(X).
  • A pdf has f(x)≥0f(x)\ge0 and total area 1; probabilities are integrals.
  • Mode: the maximum of ff. Median: the area up to mm is 12\frac12.
  • Continuous mean and variance: ∫xf(x) dx\int xf(x)\,dx and ∫x2f(x) dx−μ2\int x^2f(x)\,dx-\mu^2.

Mean and variance of a discrete variable

Weight each value, and each squared value, by its probability; variance is E(X2)−[E(X)]2E(X^2)-[E(X)]^2.

The standard deviation is Var(X)\sqrt{\text{Var}(X)}. Square each value before weighting it when finding E(X2)E(X^2).

The expected value is the long-run mean, and the variance measures spread about it.

00.10.20.30.40123xP(X = x)
Probability distribution of X
  • MeanE(X)=∑x P(X=x)E(X)=\sum x\,P(X=x)
  • Mean of squaresE(X2)=∑x2 P(X=x)E(X^2)=\sum x^2\,P(X=x)
  • VarianceE(X2)−[E(X)]2E(X^2)-[E(X)]^2

Worked example

P(X=0,1,2,3)=0.1,0.3,0.4,0.2P(X=0,1,2,3)=0.1,0.3,0.4,0.2. Find E(X)E(X) and Var(X)\text{Var}(X).

P(X=1)=0.5P(X=1)=0.5 and P(X=3)=0.5P(X=3)=0.5. What is E(X2)E(X^2)?

Linear transformations and fair games

Adding bb shifts the mean only; multiplying by aa scales the mean by aa and the variance by a2a^2.

Adding bb shifts every value, so it changes the mean but not the spread. Multiplying by aa scales the standard deviation by ∣a∣|a| and the variance by a2a^2. This is a linear transformation.

A game is fair if the player's expected gain is 0.

0246MeanVarianceQuantityValue
  • X
  • Y = 2X + 3
Illustrative values: X takes 1, 2, 3 with probabilities 0.2, 0.5, 0.3, and Y = 2X + 3. The mean becomes 2E(X) + 3; the variance becomes 4Var(X).
  • MeanE(aX+b)=aE(X)+bE(aX+b)=aE(X)+b
  • VarianceVar(aX+b)=a2 Var(X)\text{Var}(aX+b)=a^2\,\text{Var}(X)

Worked example

A player pays 8 dollars and wins 5 dollars per point scored, XX, where E(X)=1.7E(X)=1.7. Is the game fair?

Var(X)=4\text{Var}(X)=4. What is Var(3X+2)\text{Var}(3X+2)?

Continuous variables and pdfs

A function with non-negative values and total area 1, where areas give probabilities.

A continuous random variable is described by a probability density function f(x)f(x). Probabilities are areas: P(a<X<b)=∫abf(x) dxP(a<X<b)=\int_a^bf(x)\,dx. For any single value P(X=a)=0P(X=a)=0, so << and ≤\le give the same probability.

A pdf may be piecewise: integrate each piece over its own interval and add. To find an unknown constant, set the total integral equal to 1.

1234560.10.20.30.40.5xy(0, 0)(2, 1/3)(6, 0)y = f(x)
Piecewise pdf with k = 1/6. Shaded area: P(X ≤ 2) = 1/3.
  • Non-negativef(x)≥0f(x)\ge0 for all xx
  • Total area∫−∞∞f(x) dx=1\int_{-\infty}^{\infty}f(x)\,dx=1

Worked example

f(x)=kxf(x)=kx on [0,2][0,2] and f(x)=k(6−x)2f(x)=\frac{k(6-x)}{2} on (2,6](2,6]. Find kk.

Is P(X=3)P(X=3) for a continuous random variable equal to f(3)f(3)?

Mode and median

The mode is where ff is greatest; the median is where the area to its left is one half.

The mode is the xx where f(x)f(x) is greatest. Differentiate and check for a maximum, and compare with the endpoints. For f(x)=427x2(3−x)f(x)=\frac{4}{27}x^2(3-x) on [0,3][0,3], 6x−3x2=06x-3x^2=0 gives the mode x=2x=2.

The median mm has area 12\frac12 to its left. For a piecewise pdf, first find which piece contains mm by working out the probability of the first piece. If the equation gives two roots, reject the one outside the domain.

0.511.522.530.10.20.30.40.50.60.70.8xymode (2, 16/27)y = 4x²(3 − x)/27
The pdf f(x) = 4x²(3 − x)/27 peaks at the mode x = 2.
  • Median m∫−∞mf(x) dx=12\int_{-\infty}^{m}f(x)\,dx=\frac12

Why is the median of the piecewise pdf above greater than 2?

Mean and variance of a continuous variable

Replace sums by integrals over the interval where f(x)≠0f(x)\ne0.

Replace sums by integrals. In practice you only integrate over the interval where f(x)≠0f(x)\ne0. The linear transformation rules hold for continuous variables too.

On Paper 2 you may use a GDC to evaluate these integrals, but write down the integral you are evaluating to earn the method mark.

0.20.40.60.811.21.41.61.820.20.40.60.81xymean at x = 1f(x) = ¾x(2 − x)
Illustrative pdf f(x) = ¾x(2 − x) on 0 ≤ x ≤ 2: total area 1 and, by symmetry, mean E(X) = 1.
  • MeanE(X)=∫x f(x) dxE(X)=\int x\,f(x)\,dx
  • Mean of squaresE(X2)=∫x2 f(x) dxE(X^2)=\int x^2\,f(x)\,dx
  • VarianceVar(X)=E(X2)−[E(X)]2\text{Var}(X)=E(X^2)-[E(X)]^2

Worked example

f(t)=t8f(t)=\frac t8 on [0,4][0,4]. Find E(T)E(T) and Var(T)\text{Var}(T), then E(C)E(C) and Var(C)\text{Var}(C) for C=3+2.5TC=3+2.5T.

Which formula gives E(X2)E(X^2) for a continuous variable?

Try an exam question

The continuous random variable XX has probability density function f(x)=3x28f(x)=\frac{3x^2}{8} for 0≤x≤20\le x\le2, and 0 otherwise. Find (a) E(X)E(X), (b) Var(X)\text{Var}(X).

[4 marks]

That's the notes covered.

Carry on to the next subtopic.

Try a question

Find E(X2)E(X^2).

1 mark, marked against the mark scheme

Revision notes