18.2 Variance and Linear Transformations

AHL 4.14

In this section you will learn
  • how to find the variance \(\mathrm{Var}(X)\) and standard deviation of a discrete random variable
  • the useful form \(\mathrm{Var}(X) = \mathrm{E}(X^2) - [\mathrm{E}(X)]^2\)
  • the effect of a linear transformation \(aX + b\) on the mean and the variance
  • how to use these results for games and other applications

Variance and standard deviation

For a set of data, the variance \(\sigma^2\) measures how spread out the data are around the mean (see Unit 15):

\[ \sigma^2 = \frac{\sum (x - \bar{x})^2}{n} = \frac{\sum x^2}{n} - \bar{x}^2 \] or, with frequencies, \[ \sigma^2 = \frac{\sum f (x - \bar{x})^2}{\sum f} = \frac{\sum f x^2}{\sum f} - \bar{x}^2 . \]

For a random variable we do the same thing, with probabilities in place of relative frequencies. Let \(\mu = \mathrm{E}(X)\).

Variance and standard deviation of a discrete random variable In the HL formula booklet

\[ \mathrm{Var}(X) = \sum (x - \mu)^2\,\mathrm{P}(X = x) = \sum x^2\,\mathrm{P}(X = x) - \mu^2 \]

\[ \mathrm{Var}(X) = \mathrm{E}\big[(X - \mu)^2\big] = \mathrm{E}(X^2) - [\mathrm{E}(X)]^2 \]

The standard deviation is \(\sigma = \sqrt{\mathrm{Var}(X)}\).

  • \(\mathrm{Var}(X)\): the variance of \(X\)
  • \(x\): a value that \(X\) can take
  • \(\mu\): the mean of \(X\), \(\mu = \mathrm{E}(X)\)
  • \(\mathrm{P}(X = x)\): the probability that \(X\) takes the value \(x\)
  • \(\mathrm{E}(X^2)\): the expected value of \(X^2\), \(\sum x^2\,\mathrm{P}(X = x)\)
  • \(\sigma\): the standard deviation of \(X\)

The second form, “mean of the squares minus the square of the mean”, is usually quicker. A variance can never be negative. A large variance means that the values of \(X\) are widely spread around the mean (Figure 1).

Figure 1: Two random variables with the same mean, \(2\), but very different spreads.

Example 1 The probability distribution of \(X\) is shown.

\(x\) \(0\) \(1\) \(2\) \(3\) \(4\) \(5\)
\(\mathrm{P}(X = x)\) \(0.05\) \(0.15\) \(0.25\) \(0.3\) \(0.1\) \(k\)

Find

(a) the value of \(k\),

(b) \(\mathrm{E}(X)\),

(c) \(\mathrm{E}(X^2)\), \(\quad\)

(d) \(\mathrm{Var}(X)\) and the standard deviation of \(X\).

(a) \(0.05 + 0.15 + 0.25 + 0.3 + 0.1 + k = 1\), so \(0.85 + k = 1\) and \(k = 0.15\).

(b) \(\mathrm{E}(X) = 0 + 1(0.15) + 2(0.25) + 3(0.3) + 4(0.1) + 5(0.15) = 0.15 + 0.5 + 0.9 + 0.4 + 0.75 = 2.7\).

(c) \(\mathrm{E}(X^2) = 0 + 1(0.15) + 4(0.25) + 9(0.3) + 16(0.1) + 25(0.15) = 0.15 + 1 + 2.7 + 1.6 + 3.75 = 9.2\).

(d) \(\mathrm{Var}(X) = 9.2 - 2.7^2 = 9.2 - 7.29 = 1.91\).

Standard deviation \(= \sqrt{1.91} = 1.38\) (3 s.f.).

Lists & Spreadsheet: type the values of \(x\) in column A and the probabilities in column B. Then Menu → Statistics → Stat Calculations → One-Variable Statistics, with X1 List = A and Frequency List = B.

The output gives \(\bar{x} = \mathrm{E}(X)\) and \(\sigma x = \sqrt{\mathrm{Var}(X)}\). (Ignore \(sx\), which is for samples.) For Example 1: \(\bar{x} = 2.7\) and \(\sigma x = 1.38203\ldots\)

The effect of a linear transformation

Suppose every value of \(X\) is multiplied by \(a\) and then \(b\) is added. For example, a prize might be $3 for every point scored, minus a $2 fee: \(Y = 3X - 2\).

Linear transformation of a random variable In the HL formula booklet

\[ \mathrm{E}(aX + b) = a\,\mathrm{E}(X) + b \qquad\qquad \mathrm{Var}(aX + b) = a^2\,\mathrm{Var}(X) \]

  • \(X\): a random variable
  • \(a\), \(b\): constants (real numbers)

Why? For the mean,

\[ \begin{aligned} \mathrm{E}(aX + b) &= \sum (ax + b)\,\mathrm{P}(X = x) \\ &= a\sum x\,\mathrm{P}(X = x) + b\sum \mathrm{P}(X = x) \\ &= a\,\mathrm{E}(X) + b . \end{aligned} \]

For the variance: adding \(b\) moves every value and the mean by \(b\), so the spread does not change. Multiplying by \(a\) multiplies every distance from the mean by \(a\), so the squared distances are multiplied by \(a^2\).

So the standard deviation of \(aX + b\) is \(|a|\,\sigma\). Notice that \(\mathrm{Var}(-X) = \mathrm{Var}(X)\): the spread never becomes negative.

Example 2 For the random variable \(X\) in Example 1, find

(a) \(\mathrm{E}(3X + 2)\)

(b) \(\mathrm{Var}(3X + 2)\)

(c) \(\mathrm{E}(5 - 2X)\) and the standard deviation of \(5 - 2X\).

From Example 1: \(\mathrm{E}(X) = 2.7\) and \(\mathrm{Var}(X) = 1.91\).

(a) \(\mathrm{E}(3X + 2) = 3(2.7) + 2 = 10.1\).

(b) \(\mathrm{Var}(3X + 2) = 3^2 \times 1.91 = 17.19\). (The \(+2\) has no effect.)

(c) \(\mathrm{E}(5 - 2X) = 5 - 2(2.7) = -0.4\).

\(\mathrm{Var}(5 - 2X) = (-2)^2 \times 1.91 = 7.64\), so the standard deviation is \(\sqrt{7.64} = 2.76\) (3 s.f.).

Example 3 A player pays $\(c\) to roll a fair six-sided dice once. If the score is \(X\), the player receives $\(2X\).

(a) Find \(\mathrm{E}(X)\) and \(\mathrm{Var}(X)\). \(\quad\)

(b) Find the value of \(c\) that makes the game fair. \(\quad\)

(c) For this value of \(c\), find the standard deviation of the player’s profit.

(a) \(\mathrm{E}(X) = \dfrac{1 + 2 + 3 + 4 + 5 + 6}{6} = \dfrac{7}{2}\), \(\quad \mathrm{E}(X^2) = \dfrac{1 + 4 + 9 + 16 + 25 + 36}{6} = \dfrac{91}{6}\).

\[ \mathrm{Var}(X) = \frac{91}{6} - \frac{49}{4} = \frac{182 - 147}{12} = \frac{35}{12} . \]

(b) The profit is \(G = 2X - c\). Fair means \(\mathrm{E}(G) = 0\):

\[ \mathrm{E}(2X - c) = 2 \times \frac{7}{2} - c = 7 - c = 0 \;\Longrightarrow\; c = 7 . \]

(c) \(\mathrm{Var}(G) = 2^2 \times \dfrac{35}{12} = \dfrac{35}{3}\), so the standard deviation is \(\sqrt{\dfrac{35}{3}} = 3.42\) dollars (3 s.f.).

Common errors

✗ Wrong ✓ Right Why
\(\mathrm{Var}(X) = \mathrm{E}(X^2) - \mathrm{E}(X)\) \(\mathrm{E}(X^2) - [\mathrm{E}(X)]^2\) Subtract the square of the mean.
\(\mathrm{E}(X^2) = [\mathrm{E}(X)]^2\) \(\mathrm{E}(X^2) = \sum x^2\,\mathrm{P}(X = x)\) Square the values, not the mean.
\(\mathrm{Var}(3X + 2) = 3\,\mathrm{Var}(X) + 2\) \(9\,\mathrm{Var}(X)\) Multiply by \(a^2\); adding \(b\) does not change the spread.
\(\mathrm{Var}(5 - 2X) = -2\,\mathrm{Var}(X)\) \(4\,\mathrm{Var}(X)\) \((-2)^2 = 4\); a variance is never negative.
Using \(sx\) from the GDC Use \(\sigma x\) A probability distribution is a whole population, not a sample.

Exercises

1 Find \(\mathrm{E}(X)\), \(\mathrm{Var}(X)\) and the standard deviation of \(X\).

\(x\) \(1\) \(2\) \(3\)
\(\mathrm{P}(X = x)\) \(0.3\) \(0.5\) \(0.2\)

\(\mathrm{E}(X) = 0.3 + 1 + 0.6 = 1.9\). \(\quad \mathrm{E}(X^2) = 0.3 + 2 + 1.8 = 4.1\).

\(\mathrm{Var}(X) = 4.1 - 1.9^2 = 4.1 - 3.61 = 0.49\), and the standard deviation is \(\sqrt{0.49} = 0.7\).

2 \(X\) is the score on one roll of a fair four-sided dice numbered \(1, 2, 3, 4\). Find \(\mathrm{E}(X)\) and \(\mathrm{Var}(X)\).

\(\mathrm{E}(X) = \dfrac{1 + 2 + 3 + 4}{4} = \dfrac{5}{2}\). \(\quad \mathrm{E}(X^2) = \dfrac{1 + 4 + 9 + 16}{4} = \dfrac{15}{2}\).

\(\mathrm{Var}(X) = \dfrac{15}{2} - \dfrac{25}{4} = \dfrac{5}{4}\).

3 \(\mathrm{E}(X) = 4\) and \(\mathrm{Var}(X) = 3\). Find \(\mathrm{E}(2X + 1)\), \(\mathrm{Var}(2X + 1)\), \(\mathrm{E}(3 - X)\) and \(\mathrm{Var}(3 - X)\).

\(\mathrm{E}(2X + 1) = 9\), \(\quad \mathrm{Var}(2X + 1) = 4 \times 3 = 12\), \(\quad \mathrm{E}(3 - X) = -1\), \(\quad \mathrm{Var}(3 - X) = (-1)^2 \times 3 = 3\).

4 \(\mathrm{Var}(X) = 2.5\). Find the standard deviation of \(4X - 7\).

\(\mathrm{Var}(4X - 7) = 16 \times 2.5 = 40\), so the standard deviation is \(\sqrt{40} = 6.32\) (3 s.f.).

5 \(\mathrm{P}(X = x) = \dfrac{x}{10}\) for \(x = 1, 2, 3, 4\). Find \(\mathrm{E}(X)\) and \(\mathrm{Var}(X)\).

\(\mathrm{E}(X) = \dfrac{1 + 4 + 9 + 16}{10} = 3\). \(\quad \mathrm{E}(X^2) = \dfrac{1 + 8 + 27 + 64}{10} = 10\).

\(\mathrm{Var}(X) = 10 - 9 = 1\).

6 The distribution of \(X\) is shown, and \(\mathrm{E}(X) = 0.4\). Find \(a\) and \(b\), and then \(\mathrm{Var}(X)\).

\(x\) \(-1\) \(0\) \(2\)
\(\mathrm{P}(X = x)\) \(a\) \(0.5\) \(b\)

\(a + b = 0.5\) and \(-a + 2b = 0.4\). Adding: \(3b = 0.9\), so \(b = 0.3\) and \(a = 0.2\).

\(\mathrm{E}(X^2) = 1(0.2) + 0 + 4(0.3) = 1.4\), so \(\mathrm{Var}(X) = 1.4 - 0.4^2 = 1.24\).

7 \(\mathrm{E}(X) = 10\) and \(\mathrm{Var}(X) = 4\). Find constants \(a > 0\) and \(b\) so that \(Y = aX + b\) has \(\mathrm{E}(Y) = 0\) and \(\mathrm{Var}(Y) = 1\).

\(\mathrm{Var}(Y) = 4a^2 = 1\), so \(a = \dfrac{1}{2}\) (as \(a > 0\)).

\(\mathrm{E}(Y) = \dfrac{1}{2}(10) + b = 0\), so \(b = -5\). (So \(Y = \dfrac{X - 10}{2}\).)

8 The midday temperature \(X\) °C in a city has mean \(20\) and standard deviation \(3\). The temperature in °F is \(F = 1.8X + 32\). Find the mean and standard deviation of \(F\).

\(\mathrm{E}(F) = 1.8(20) + 32 = 68\) °F. Standard deviation \(= 1.8 \times 3 = 5.4\) °F (the \(+32\) has no effect).

9 Two fair coins are tossed, and \(X\) is the number of heads. A player pays $\(c\) and receives $\(5X\).

(a) Find \(\mathrm{E}(X)\) and \(\mathrm{Var}(X)\).

(b) Find \(c\) for a fair game.

(c) Find the variance of the profit.

(a) \(\mathrm{P}(X = 0, 1, 2) = \frac{1}{4}, \frac{1}{2}, \frac{1}{4}\). \(\;\mathrm{E}(X) = 1\), \(\;\mathrm{E}(X^2) = \frac{1}{2} + 1 = \frac{3}{2}\), \(\;\mathrm{Var}(X) = \frac{1}{2}\).

(b) Profit \(= 5X - c\), and \(\mathrm{E}(5X - c) = 5 - c = 0\), so \(c = 5\).

(c) \(\mathrm{Var}(5X - c) = 25 \times \dfrac{1}{2} = 12.5\).

10 \(\mathrm{E}(X) = 2\) and \(\mathrm{E}(X^2) = 7\). Find \(\mathrm{Var}(X)\), \(\mathrm{Var}(3X)\) and \(\mathrm{E}\big((X - 1)^2\big)\).

\(\mathrm{Var}(X) = 7 - 4 = 3\), and \(\mathrm{Var}(3X) = 9 \times 3 = 27\).

\[ \mathrm{E}\big((X - 1)^2\big) = \sum (x^2 - 2x + 1)\,\mathrm{P}(X = x) = \mathrm{E}(X^2) - 2\,\mathrm{E}(X) + 1 = 7 - 4 + 1 = 4 . \]