4.14 · AHL · HL onlyPaper 1Paper 2Paper 3

Discrete and continuous random variables

In a minute

The measures how spread out a random variable is, and Var(X)=E(X2)−[E(X)]2\mathrm{Var}(X) = \mathrm{E}(X^{2}) - \left[\mathrm{E}(X)\right]^{2} is the quick way to find it. A continuous variable is described by a : probabilities are areas under it, and integrals give its mean, variance, median and mode.

You'll be able to

  • Find E(X2)\mathrm{E}(X^{2}), the variance and the standard deviation of a discrete random variable.
  • Use a probability density function, including a piecewise one: find an unknown constant and find probabilities as areas.
  • Find the mode from the maximum of the density and the median from half the area.
  • Find the mean, variance and standard deviation of a continuous random variable by integration.
  • Use E(aX+b)=aE(X)+b\mathrm{E}(aX + b) = a\mathrm{E}(X) + b and Var(aX+b)=a2Var(X)\mathrm{Var}(aX + b) = a^{2}\mathrm{Var}(X), including to make a game fair.
Before you start3 quick questions on what this builds on
Check yourself
XX takes the values 11, 22 and 55 with probabilities 0.50.5, 0.30.3 and 0.20.2. Find E(X)\mathrm{E}(X).
Check yourself
Find the exact value of ∫02(3x2−x) dx\int_{0}^{2} (3x^{2} - x)\,\mathrm{d}x.
Check yourself
The curve y=12x−2x3y = 12x - 2x^{3} has a local maximum for some x>0x > 0. Find that value of xx.

Revise first: 4.7 Discrete random variables and expected value, 5.8 Extrema, inflexion and optimisation and 5.11 Definite integrals and areas

Variance of a discrete random variable

In 4.7 you found the E(X)\mathrm{E}(X), the long-run mean of a . The mean alone hides a lot.

Picture two games that both pay $5 on average. One always pays $5. The other pays $0 or $10 with equal chance. Same mean, very different risk. You need a number for the spread.

Squaring stops the distances above and below the mean from cancelling. It also means a variance is never negative. If you get a negative variance, look for a slip.

Working out every (x−μ)2(x - \mu)^{2} is slow. Expanding the bracket gives a quicker form. You need E(X2)\mathrm{E}(X^{2}), the expected value of X2X^{2}: square each value, then weight it by its probability.

Learn this
E(X2)=∑x2 P(X=x)\mathrm{E}(X^{2}) = \sum x^{2}\,\mathrm{P}(X = x)
In the formula booklet
Var(X)=E[(X−μ)2]=E(X2)−[E(X)]2\mathrm{Var}(X) = \mathrm{E}\left[(X - \mu)^{2}\right] = \mathrm{E}(X^{2}) - \left[\mathrm{E}(X)\right]^{2}
In the formula booklet
Var(X)=∑(x−μ)2 P(X=x)=∑x2 P(X=x)−μ2\mathrm{Var}(X) = \sum (x - \mu)^{2}\,\mathrm{P}(X = x) = \sum x^{2}\,\mathrm{P}(X = x) - \mu^{2}

Both forms are in the formula booklet. Read the second one as: the mean of the squares, minus the square of the mean.

Worked exampleXX takes the values 1,2,3,41, 2, 3, 4 with probabilities 0.1,0.3,0.4,0.20.1, 0.3, 0.4, 0.2. Find Var(X)\mathrm{Var}(X).

Try it first, then reveal one step at a time.

  1. Find the mean: E(X)=1(0.1)+2(0.3)+3(0.4)+4(0.2)=0.1+0.6+1.2+0.8=2.7\mathrm{E}(X) = 1(0.1) + 2(0.3) + 3(0.4) + 4(0.2) = 0.1 + 0.6 + 1.2 + 0.8 = 2.7.
Worked exampleXX takes the values 0,1,2,30, 1, 2, 3 with probabilities 0.2,p,q,0.10.2, p, q, 0.1. Given that E(X)=1.4\mathrm{E}(X) = 1.4, find pp and qq, then find Var(X)\mathrm{Var}(X).

Try it first, then reveal one step at a time.

  1. The probabilities add up to 11: 0.2+p+q+0.1=10.2 + p + q + 0.1 = 1, so p+q=0.7p + q = 0.7.
Check yourself
P(X=x)=x10\mathrm{P}(X = x) = \frac{x}{10} for x=1,2,3,4x = 1, 2, 3, 4. Given that E(X)=3\mathrm{E}(X) = 3, find Var(X)\mathrm{Var}(X).
Check yourself
XX takes the values −2-2, 00 and 33 with probabilities 0.250.25, 0.50.5 and 0.250.25. Find the standard deviation of XX. Give your answer to 3 s.f.

The same formula works for data in a frequency table. There, each relative frequency fin\frac{f_{i}}{n} plays the part of a probability, as in 4.3.

In the formula booklet
σ2=∑i=1kfi(xi−μ)2n=∑i=1kfixi2n−μ2\sigma^{2} = \frac{\sum_{i=1}^{k} f_{i}(x_{i} - \mu)^{2}}{n} = \frac{\sum_{i=1}^{k} f_{i}x_{i}^{2}}{n} - \mu^{2}

Continuous random variables and density functions

A can take any value in an interval, such as a waiting time. You can't list its values, so you can't give each one a probability.

Instead, probability is spread along the xx-axis like paint, thick in some places and thin in others. A curve shows how thick. The probability of landing between aa and bb is the area under the curve there.

Learn this
∫−∞∞f(x) dx=1\int_{-\infty}^{\infty} f(x)\,\mathrm{d}x = 1
Learn this
P(a≤X≤b)=∫abf(x) dx\mathrm{P}(a \le X \le b) = \int_{a}^{b} f(x)\,\mathrm{d}x

In practice f(x)=0f(x) = 0 outside some interval. So the integral only runs over the interval where ff is non-zero, using the where the formula applies.

A single point has no width, so P(X=a)=0\mathrm{P}(X = a) = 0. That means P(X<b)\mathrm{P}(X < b) and P(X≤b)\mathrm{P}(X \le b) are equal. Also, f(x)f(x) itself is not a probability. It can even be bigger than 11.

Worked exampleXX has pdf f(x)=kx(3−x)2f(x) = kx(3 - x)^{2} for 0≤x≤30 \le x \le 3, and f(x)=0f(x) = 0 otherwise. Find the value of kk.

Try it first, then reveal one step at a time.

  1. The total area is 11: ∫03kx(3−x)2 dx=1\int_{0}^{3} kx(3 - x)^{2}\,\mathrm{d}x = 1.

A density uses different formulas on different intervals. Split every integral at the points where the formula changes, and add the pieces.

Worked exampleXX has pdf f(x)=kx2f(x) = kx^{2} for 0≤x≤10 \le x \le 1, f(x)=kf(x) = k for 1<x≤31 < x \le 3, and f(x)=0f(x) = 0 otherwise. Find kk, then find P(X≤2)\mathrm{P}(X \le 2).

Try it first, then reveal one step at a time.

  1. Split the total at x=1x = 1: ∫01kx2 dx+∫13k dx=1\int_{0}^{1} kx^{2}\,\mathrm{d}x + \int_{1}^{3} k\,\mathrm{d}x = 1.
Check yourself
XX has pdf f(x)=kxf(x) = k\sqrt{x} for 0≤x≤40 \le x \le 4, and 00 otherwise. Find kk.
Check yourself
For the piecewise density in the last example, with k=37k = \frac{3}{7}, find P(X>2.5)\mathrm{P}(X > 2.5). Give your answer to 3 s.f.

Mode and median

The mode and the median mean the same as for data in 4.3. For a density, you find them from the curve.

To find it, use 5.8: solve f′(x)=0f'(x) = 0 and check it is a maximum. Also compare the values at the ends of the interval, since the maximum can sit at an end. The mode is the xx-value, not the height f(x)f(x).

Learn this
∫−∞mf(x) dx=12\int_{-\infty}^{m} f(x)\,\mathrm{d}x = \frac{1}{2}
Worked exampleXX has pdf f(x)=427x(3−x)2f(x) = \frac{4}{27}x(3 - x)^{2} for 0≤x≤30 \le x \le 3, and 00 otherwise. Find the mode of XX.

Try it first, then reveal one step at a time.

  1. Expand: f(x)=427(9x−6x2+x3)f(x) = \frac{4}{27}(9x - 6x^{2} + x^{3}).

For the median of a piecewise density, first find how much probability the first piece holds. That tells you which piece the median is in. The picture below shows it for the density from the last section.

A piecewise density: a curve rising from 0 to 3/7 between x = 0 and 1, then flat at 3/7 up to x = 3. The area from 0 to the median 11/6 is shaded and equals one half. x y O 1 2 3 3/7 y = f(x) area 1/2 m = 11/6
The median m=116m = \frac{11}{6} cuts off half the area. Only 17\frac{1}{7} of it lies below x=1x = 1.
Worked exampleXX has pdf f(x)=37x2f(x) = \frac{3}{7}x^{2} for 0≤x≤10 \le x \le 1, f(x)=37f(x) = \frac{3}{7} for 1<x≤31 < x \le 3, and 00 otherwise. Find the median of XX.

Try it first, then reveal one step at a time.

  1. Find the area of the first piece: ∫0137x2 dx=17\int_{0}^{1} \frac{3}{7}x^{2}\,\mathrm{d}x = \frac{1}{7}.

Often the median equation can't be solved by algebra. On Paper 2, write the equation down, then solve it on your calculator.

Worked exampleXX has pdf f(x)=427x(3−x)2f(x) = \frac{4}{27}x(3 - x)^{2} for 0≤x≤30 \le x \le 3, and 00 otherwise. Use your calculator to find the median of XX. Give your answer to 3 s.f.

Try it first, then reveal one step at a time.

  1. The median satisfies ∫0m427(9x−6x2+x3) dx=12\int_{0}^{m} \frac{4}{27}(9x - 6x^{2} + x^{3})\,\mathrm{d}x = \frac{1}{2}.
Check yourself
XX has pdf f(x)=34x2(2−x)f(x) = \frac{3}{4}x^{2}(2 - x) for 0≤x≤20 \le x \le 2, and 00 otherwise. Find the mode of XX.
Check yourself
XX has pdf f(x)=38x2f(x) = \frac{3}{8}x^{2} for 0≤x≤20 \le x \le 2, and 00 otherwise. Find the exact median of XX.

Mean and variance of a continuous random variable

For a discrete variable, E(X)=∑x P(X=x)\mathrm{E}(X) = \sum x\,\mathrm{P}(X = x). For a continuous one, the sum becomes an integral, and P(X=x)\mathrm{P}(X = x) becomes f(x) dxf(x)\,\mathrm{d}x, the probability in a thin strip.

In the formula booklet
E(X)=μ=∫−∞∞xf(x) dx\mathrm{E}(X) = \mu = \int_{-\infty}^{\infty} x f(x)\,\mathrm{d}x
In the formula booklet
Var(X)=∫−∞∞(x−μ)2f(x) dx=∫−∞∞x2f(x) dx−μ2\mathrm{Var}(X) = \int_{-\infty}^{\infty} (x - \mu)^{2} f(x)\,\mathrm{d}x = \int_{-\infty}^{\infty} x^{2} f(x)\,\mathrm{d}x - \mu^{2}

These are in the formula booklet. The second form is again E(X2)−[E(X)]2\mathrm{E}(X^{2}) - \left[\mathrm{E}(X)\right]^{2}, with E(X2)=∫x2f(x) dx\mathrm{E}(X^{2}) = \int x^{2} f(x)\,\mathrm{d}x. The standard deviation is σ=Var(X)\sigma = \sqrt{\mathrm{Var}(X)}, as before.

If the density is symmetric about a line x=cx = c, the mean is cc. You can state it without integrating.

Worked exampleXX has f(x)=427x(3−x)2f(x) = \frac{4}{27}x(3 - x)^{2} for 0≤x≤30 \le x \le 3, and 00 otherwise. Find E(X)\mathrm{E}(X) and Var(X)\mathrm{Var}(X).

Try it first, then reveal one step at a time.

  1. Multiply by xx first: xf(x)=427(9x2−6x3+x4)x f(x) = \frac{4}{27}(9x^{2} - 6x^{3} + x^{4}).
Worked exampleXX has pdf f(x)=37x2f(x) = \frac{3}{7}x^{2} for 0≤x≤10 \le x \le 1, f(x)=37f(x) = \frac{3}{7} for 1<x≤31 < x \le 3, and 00 otherwise. Use your calculator to find the standard deviation of XX. Give your answer to 3 s.f.

Try it first, then reveal one step at a time.

  1. Split each integral at x=1x = 1. Write what you enter: E(X)=∫0137x3 dx+∫1337x dx=1.821428…\mathrm{E}(X) = \int_{0}^{1} \frac{3}{7}x^{3}\,\mathrm{d}x + \int_{1}^{3} \frac{3}{7}x\,\mathrm{d}x = 1.821428\ldots
Check yourself
XX has pdf f(x)=38x2f(x) = \frac{3}{8}x^{2} for 0≤x≤20 \le x \le 2, and 00 otherwise, so E(X)=32\mathrm{E}(X) = \frac{3}{2}. Find Var(X)\mathrm{Var}(X).
Check yourself
XX has pdf f(x)=316xf(x) = \frac{3}{16}\sqrt{x} for 0≤x≤40 \le x \le 4, and 00 otherwise. Find the standard deviation of XX. Give your answer to 3 s.f.

Linear transformations and fair games

Suppose every value of XX is doubled and then 55 is added. The mean is doubled and moved up by 55. The spread doubles too, but adding 55 doesn't change it: every value slides along together.

Variance is measured in squared units. So when the values are multiplied by aa, the variance is multiplied by a2a^{2}. This works for discrete and continuous variables alike.

In the formula booklet
E(aX+b)=aE(X)+b,Var(aX+b)=a2Var(X)\mathrm{E}(aX + b) = a\mathrm{E}(X) + b, \quad \mathrm{Var}(aX + b) = a^{2}\mathrm{Var}(X)

Take the square root of the variance rule to get the standard deviation rule. The modulus is there because a standard deviation is never negative.

Learn this
σaX+b=∣a∣ σX\sigma_{aX + b} = \lvert a\rvert\,\sigma_{X}
Worked exampleThe time XX hours of a repair job has E(X)=65\mathrm{E}(X) = \frac{6}{5} and Var(X)=925\mathrm{Var}(X) = \frac{9}{25}. A firm charges Y=40X+15Y = 40X + 15 dollars per job. Find E(Y)\mathrm{E}(Y) and Var(Y)\mathrm{Var}(Y).

Try it first, then reveal one step at a time.

  1. Here a=40a = 40 and b=15b = 15.

In 4.7 you met a : one where the player's expected gain is 00. When a gain is built from a prize, a fee and a multiplier, the rule for E(aX+b)\mathrm{E}(aX + b) gives the fair fee in one line.

Worked exampleA spinner pays a prize of XX dollars, where XX takes the values 0,2,5,100, 2, 5, 10 with probabilities 0.4,0.3,0.2,0.10.4, 0.3, 0.2, 0.1. For one day, prizes are doubled, and a player pays cc dollars to play. Find cc so that the game is fair.

Try it first, then reveal one step at a time.

  1. Find the mean prize: E(X)=0+2(0.3)+5(0.2)+10(0.1)=0.6+1+1=2.6\mathrm{E}(X) = 0 + 2(0.3) + 5(0.2) + 10(0.1) = 0.6 + 1 + 1 = 2.6.
Check yourself
Var(X)=4\mathrm{Var}(X) = 4. Find Var(5−3X)\mathrm{Var}(5 - 3X).
Check yourself
XX has mean 1212 and standard deviation 33. Find the standard deviation of Y=0.5X−4Y = 0.5X - 4.

Common mistakes

  • Stopping at E(X2)\mathrm{E}(X^{2}) and calling it the variance. Always subtract [E(X)]2\left[\mathrm{E}(X)\right]^{2}.
  • Integrating f(x)f(x) instead of xf(x)x f(x) for the mean. That just gives the total probability, 11.
  • Using only one piece of a piecewise density, or the wrong limits. Split each integral where the formula changes, and start from the lowest value of XX.
  • Giving the height of the density as the mode. The mode is the xx-value where ff is largest.
  • Giving the variance when the question asks for the standard deviation. Take the square root.
  • Rounding E(X)\mathrm{E}(X) before squaring it. Store the full calculator value and round only the final answer.

Exam tips

  • Show that a constant is kk: write ∫f(x) dx=1\int f(x)\,\mathrm{d}x = 1 over the whole range first, then work forwards to the given value. Don't start from the answer.
  • On Paper 2, write down the integral or equation you put into the calculator, such as ∫0mf(x) dx=0.5\int_{0}^{m} f(x)\,\mathrm{d}x = 0.5. That line earns the method mark.
  • State or write down E(X)\mathrm{E}(X) for a symmetric density: the line of symmetry is the mean, and no working is needed.
  • For a median, check your answer lies in the interval where the density is non-zero, and in the piece you used.

Key takeaways

In bookletVar(X)=E[(X−μ)2]=E(X2)−[E(X)]2\mathrm{Var}(X) = \mathrm{E}\left[(X - \mu)^{2}\right] = \mathrm{E}(X^{2}) - \left[\mathrm{E}(X)\right]^{2}
Learn this∫−∞∞f(x) dx=1\int_{-\infty}^{\infty} f(x)\,\mathrm{d}x = 1
Learn thisP(a≤X≤b)=∫abf(x) dx\mathrm{P}(a \le X \le b) = \int_{a}^{b} f(x)\,\mathrm{d}x
Learn this∫−∞mf(x) dx=12\int_{-\infty}^{m} f(x)\,\mathrm{d}x = \frac{1}{2}
In bookletE(X)=μ=∫−∞∞xf(x) dx\mathrm{E}(X) = \mu = \int_{-\infty}^{\infty} x f(x)\,\mathrm{d}x
In bookletVar(X)=∫−∞∞(x−μ)2f(x) dx=∫−∞∞x2f(x) dx−μ2\mathrm{Var}(X) = \int_{-\infty}^{\infty} (x - \mu)^{2} f(x)\,\mathrm{d}x = \int_{-\infty}^{\infty} x^{2} f(x)\,\mathrm{d}x - \mu^{2}
In bookletE(aX+b)=aE(X)+b,Var(aX+b)=a2Var(X)\mathrm{E}(aX + b) = a\mathrm{E}(X) + b, \quad \mathrm{Var}(aX + b) = a^{2}\mathrm{Var}(X)
Learn thisσaX+b=∣a∣ σX\sigma_{aX + b} = \lvert a\rvert\,\sigma_{X}
In bookletVar(X)=E(X2)−[E(X)]2,σ=Var(X)\mathrm{Var}(X) = \mathrm{E}(X^{2}) - \left[\mathrm{E}(X)\right]^{2}, \quad \sigma = \sqrt{\mathrm{Var}(X)}
Learn thisA pdf has f(x)≥0f(x) \ge 0 and total area ∫f(x) dx=1\int f(x)\,\mathrm{d}x = 1. Probabilities are areas, so P(X=a)=0\mathrm{P}(X = a) = 0.
Learn thisSplit every integral of a piecewise density where the formula changes, and include every piece.
Learn thisMode: the xx where ff is largest (check the ends too). Median: ∫−∞mf(x) dx=12\int_{-\infty}^{m} f(x)\,\mathrm{d}x = \frac{1}{2}.
Learn thisE(X)=∫xf(x) dx,E(X2)=∫x2f(x) dx\mathrm{E}(X) = \int x f(x)\,\mathrm{d}x, \quad \mathrm{E}(X^{2}) = \int x^{2} f(x)\,\mathrm{d}x
Learn thisA game is fair when the player's expected gain is 00.

Practise this

19 past-paper questions on 4.14 in the AA HL bank, each with a mark scheme and a worked explanation.

Practise 4.14 →