Expected Value & Linearity
Linearity of Expectation Tricks
Overview
Linearity of expectation is magical. It says: to find E[sum of things], just add up E[each thing] — even if the things are wildly dependent. The indicator variable trick transforms 'expected count of X' into 'sum of probabilities of each X occurring'. This bypasses the need to know the full joint distribution. Once you see this technique, you use it everywhere.
How to Recognize
- →Hard to enumerate all outcomes — too many cases
- →Asked for expected count of something (matches, crossings, inversions)
- →Problem has symmetric or exchangeable structure
- →Each 'piece' of the answer is independent or symmetric
Step-by-Step Approach
- 1.Define indicator Iᵢ = 1 if event i occurs, 0 otherwise
- 2.E[total count] = E[ΣIᵢ] = ΣE[Iᵢ] = ΣP(event i occurs)
- 3.Each P(event i) is usually MUCH easier to compute than the full distribution
- 4.Use symmetry: if all events are exchangeable, E = n·P(one event occurs)
Key Formulas
Worked Examples
Problem
A deck of 52 cards is shuffled randomly and placed next to an ordered reference deck. What is the expected number of positions where both decks have the same card?
Solution
Define Iᵢ = 1 if card i is in position i in the shuffled deck.
P(Iᵢ = 1) = P(card i is in position i) = 1/52 for every card.
By linearity: E[total matches] = Σ P(Iᵢ = 1) = 52 · (1/52) = 1.
Mind-blowing: it doesn't matter if n=1 or n=1,000,000. The answer is always 1.
This is the expected number of fixed points of a random permutation.
Answer
regardless of deck size . The expected number of fixed points in any random permutation is always exactly 1.
Common Mistakes
- !
Thinking linearity requires independence. E[X+Y] = E[X] + E[Y] ALWAYS — even if X and Y are perfectly correlated. Independence is NOT required.
- !
Not defining indicators carefully. The event must be something that either happens or doesn't for each piece of the sum.
- !
Trying to compute the full distribution when linearity would give the expected value directly and easily.
Practice Problems
Click "Show Answer" to revealRoll 10 fair dice. What is the expected number of 6s?
Randomly arrange n people in a line. What is the expected number of adjacent pairs where person A is taller than the adjacent person B (A is immediately to B's left)?
A box has 10 balls: 4 red, 6 blue. Draw 3 without replacement. Expected number of red balls?