Linearity of Expectation, Even Without Independence
The expected value of a sum always equals the sum of the expected values — even when the pieces are wildly dependent on each other. That one fact quietly solves half the hard-looking counting puzzles in an interview.
Prerequisites: Expectation, Variance & Moments
A hundred people check their coats at a party, and the coats are handed back in a completely random order. What's the expected number of people who get their own coat back? Nobody wants to compute the probability of "exactly matches" for every from 0 to 100 and average — that's a nightmare of derangement counting. Yet the answer is one line, exactly 1, regardless of whether there are 5 people or 5 million.
Try it before reading on: guess whether the answer depends on the number of people, then see if you can find the one-line argument.
The trap: trying to compute the full distribution
The instinct is to find for every , using derangement formulas, then compute . That's real combinatorics, genuinely hard to do under time pressure, and completely unnecessary — because expectation of a sum doesn't care about the joint distribution of the pieces at all.
Linearity of expectation: for any random variables , — always, with no assumption of independence. Break a hard total into a sum of simple 0/1 indicator variables, find each one's easy individual expectation, and add.
This is the single most useful sentence in interview probability because it lets you dodge every hard joint-distribution question by never asking about the joint distribution at all.
Worked example: the hat-check problem
Let be the indicator variable that equals 1 if person gets their own coat back, 0 otherwise, for . The total number of matches is , and
In words: the expected total number of matches is just the sum, over each person, of the chance that particular person matches — and crucially this holds even though are heavily dependent (if person 1 gets their coat, that changes the odds for everyone else). Linearity doesn't care.
Each individual is easy: with a uniformly random permutation of coats, person 's coat lands in any of the positions with equal probability, so . Summing copies of : . Exactly one match expected, for any — 5 people or 5 million, the answer never changes, which is the counterintuitive punchline that makes this a favourite interview question.
Worked example: the birthday-collision count, not just the probability
A room has 30 people. Instead of the classic "probability at least two share a birthday," ask the linearity-friendly version: what's the expected number of pairs who share a birthday? There are pairs. For any specific pair, the chance they share a birthday (ignoring leap years, 365 equally likely days) is , because once the first person's birthday is fixed, the second matches it with probability regardless of everyone else.
In words: sum, over all possible pairs, the (tiny, identical) probability that that specific pair matches. You'd expect just over one matching pair among 30 people — consistent with the well-known fact that the probability of at least one match at 30 people is already around 70%, since even a fractional expected count above 1 corresponds to a substantial chance of at least one occurring.
The recipe is always the same three steps: (1) write the quantity you want as a sum of 0/1 indicators for simple events, (2) find each indicator's expectation — usually just "the probability of one thing happening," often by symmetry, (3) add them up. Step 2 is almost always the easy part; the skill is spotting step 1, seeing which sum of indicators reconstructs your total.
Linearity of expectation gives you , not the distribution or variance of — you cannot use it to claim, say, that matches are unlikely to cluster, or to compute . People sometimes over-extend "the pieces don't need to be independent" into "so I don't need to think about dependence at all," which is true for the mean and false for everything else about the distribution. If a question asks for a probability, not an expectation, linearity alone won't finish the job.
The transferable technique
Whenever a problem asks for an expected count of something — matches, fixed points, collisions, successes, inversions — resist counting all the ways it can happen and instead decompose the count into indicator variables for the smallest atomic event you can name, compute each one's probability using symmetry or a direct argument, and sum. This single habit turns some of the ugliest-looking combinatorics questions in an interview into two lines of arithmetic.
Related concepts
Practice in interviews
Further reading
- Blitzstein & Hwang, Introduction to Probability, ch. 4