Back to the on-screen lesson ·

Linearity of expectation

Expectations of sums add whatever the variables do to each other, and the indicator method that turns that into a counting technique.

Paper packet. Every task here also exists on screen, where it is checked automatically; answers written on paper are not assessed by Nydus. When you are back at a device, enter your answers there.

1. What you will learn

You will compute the expectation of any linear combination of random variables from their individual expectations, without knowing anything about how they are related, and you will use the indicator method to find the expected size of a count whose own distribution would be hard to write down. You will also say which rules do need independence and why.

2. Two rules already met

Scaling and shifting a single variable moved its expectation in the obvious way. This lesson adds the one remaining piece — what happens to a sum of two variables — and it is the piece that does almost all the work.

3. Words for this lesson

A rule is linear when it passes through sums and through multiplication by a constant. An indicator $I_A$ is the variable that is $1$ when $A$ happens and $0$ otherwise, so its expectation is exactly $P(A)$. The indicator method writes a count as a sum of indicators and expects them one at a time.

4. Expectations of sums add, unconditionally

For any random variables on the same sample space, and any constants,

$$E[a X + b Y + c] = a\,E[X] + b\,E[Y] + c.$$

The proof is one line over the joint distribution: sum $(aX(\omega) + bY(\omega) + c)P(\{\omega\})$ outcome by outcome and split the sum into three. Nothing in that argument asks the joint distribution to factorise, so no independence is required — and that is the whole point. $X$ and $Y$ may determine each other completely and the rule still holds.

Compare it with what comes later: $\operatorname{Var}(X + Y)$ does need independence, or else a covariance term. Expectation is the one summary that passes through a sum untouched, and almost every clever argument in probability is that fact being exploited.

The exploitation has a standard shape, the indicator method. To count things, define $I_k = 1$ when the $k$-th thing happens and $0$ otherwise. Then $E[I_k] = P(\text{it happens})$ — an indicator's expectation is just its probability — and the count is $\sum_k I_k$, so its expectation is $\sum_k P(\text{the } k\text{-th happens})$. The distribution of the count may be hopeless; the expectation is a line.

Another way: story

Twenty people put their hats at a door and take one back at random. How many get their own? The distribution of that count is genuinely awkward. The expectation is not: each person has one chance in twenty, there are twenty of them, and the answer is one — whatever the number of people.

Another way: steps

  1. Write the quantity as a sum, ideally of indicators.
  2. Expect one term on its own; for an indicator that is a probability.
  3. Add the expectations.
  4. Say out loud that the joint distribution was not needed — it is the step that makes the method worth using.

5. What needs independence and what does not

The distinction is worth having in one place.

StatementNeeds independence
$E[X + Y] = E[X] + E[Y]$no
$E[aX + b] = aE[X] + b$no
$E[XY] = E[X]E[Y]$yes
$\operatorname{Var}(X + Y) = \operatorname{Var}(X) + \operatorname{Var}(Y)$yes (or zero covariance)

The two that need it are the two involving products, and a variance is built out of a product. Sums are free; products are not.

6. Where this goes wrong

Believing linearity needs independence. It does not, and thinking it does means abandoning the rule exactly when it is most useful.

Extending it to products. $E[XY] = E[X]E[Y]$ is a different statement and it does need independence.

Extending it to variances. Variances of sums add only when the covariance vanishes.

Extending it to non-linear functions. $E[X^{2}] \ne (E[X])^{2}$ and $E[1/X] \ne 1/E[X]$. The rule is called linearity because linear is exactly what it covers.

7. Two dice

  1. $X$ and $Y$ are the two faces; each has expectation $3.5$.

    Same distribution, and here independent too.

  2. $E[X + Y] = 7$ without touching the distribution of the total.

    Which has eleven values and unequal probabilities.

  3. And $E[X - Y] = 0$ by the same rule.

    Sums and differences alike.

8. An indicator count

  1. A coin is tossed $n$ times; $X$ counts the heads. Let $I_k$ be $1$ on a head at toss $k$.

    Write the count as a sum.

  2. $E[I_k] = p$, so $E[X] = np$.

    One term, then linearity.

  3. The binomial mean, derived without summing $k \binom{n}{k} p^{k}(1-p)^{n-k}$ even once.

    The hard sum was never needed.

9. Your turn: a fair die is rolled $30$ times; find the expected number of sixes

  1. Let $I_k$ be $1$ when roll $k$ is a six, and write the count as $I_1 + \cdots + I_{30}$.

    A sum of indicators.

  2. $E[I_k] = 1/6$ for each.

    An indicator's expectation is its probability.

  3. Your turn: work this step out. Its working is at the end of the packet.

    So the expected number is $30 \times 1/6 = 5$.

10. Guided practice

$X$ has expectation $8$ and $Y$ has expectation $3$. Nothing is said about how they are related. Give the four expectations.

Value
$E[X]$
$E[X + Y]$
$E[2X + 3Y]$
$E[X - Y]$

11. Guided practice

$E[X] = 6$ and $E[Y] = 4$. Give $E[X + Y + 3]$ and $E[X - Y]$.

$E[X + Y + 3]$ is p and $E[X - Y]$ is q.

12. Practice

$X$ is the number showing on a fair die and $Y$ is $6$ minus that same number, so the two are as dependent as two variables can be. What is $E[X + Y]$, and what did the calculation need?

13. Practice

$E[X] = 7$ and $E[Y] = 5$. Match each expression to its expectation.

$7$$5$$12$$2$
$E[X]$
$E[Y]$
$E[X + Y]$
$E[X - Y]$

14. Somewhere new

$12$ people leave their hats at a door and each takes one back at random, all arrangements equally likely. What is the expected number of people who get their own hat?

Answer:

15. Lesson test

Lesson test: one question per skill, one attempt each, no hints. Your answers are checked when you submit.

16. Test question

Put the steps of an indicator argument into the order they are carried out in, for a count over $7$ items.

Number the steps in order (write the number in the box):

17. What you can do now

You can combine expectations linearly and write a count as a sum of indicators to find its expectation. Say in your own words why linearity does not need independence while the rule for the expectation of a product does.

Working for the steps left to you

9. Your turn: a fair die is rolled $30$ times; find the expected number of sixes, step 3