Course contentsShow
← Computer Science
Lesson 132 of 2,8723. Probability for Computer ScienceFree lesson

Linearity of Expectation

Discover why expectation distributes over sums regardless of independence, simplifying many calculations.

Linearity of Expectation

What You'll Learn

You'll discover why expectation distributes over sums regardless of independence, making complex probability calculations dramatically simpler.


The Core Idea

Linearity of Expectation states that the expected value of a sum equals the sum of the expected values:

E[X + Y] = E[X] + E[Y]

This works for any random variables X and Y—they don't need to be independent! This is remarkable and incredibly useful.

Why This Matters

When you learned about expected values, you saw how to compute E[X] for a single random variable. But what if you need the expected value of multiple random variables combined? Linearity of expectation says: just add up their individual expectations.

An Analogy

Imagine you're counting expected coins from two mystery boxes. Box A gives you an average of 3 coins, Box B gives you an average of 5 coins. How many coins do you expect total? 8 coins—even if the boxes are linked somehow (maybe both give more on rainy days). The independence doesn't matter; the averages still add up.

The Math

For any random variables X and Y, and constants a and b:

E[aX + bY] = aE[X] + bE[Y]

This extends to any number of variables:

E[X₁ + X₂ + ... + Xₙ] = E[X₁] + E[X₂] + ... + E[Xₙ]

Example Application

Suppose you flip 100 coins. Let Xᵢ = 1 if coin i is heads, 0 otherwise. Each E[Xᵢ] = 0.5. The expected number of heads is:

E[X₁ + X₂ + ... + X₁₀₀] = 100 × 0.5 = 50

No complicated probability calculations needed!


Key Takeaway: Linearity of expectation lets you break complex problems into simple pieces—the expected value of a sum always equals the sum of expected values, even without independence.