On this page
Many expected-value questions seem to need a full probability distribution. If the quantity is a count, you can usually skip it and add a few simple probabilities instead. The trick has two parts, linearity of expectation and indicator variables, and it is a useful tool for JEE Advanced probability and olympiad combinatorics.
What is linearity of expectation?
For any two random variables X and Y, E[X + Y] = E[X] + E[Y]. Stanford's CS109 course reader stresses that this is true regardless of the relationship between X and Y, which can be dependent and can have different distributions. The same holds for a sum of any number of variables.
That surprises students, because P(A and B) = P(A)P(B) needs independence, and adding variances needs the variables to be uncorrelated. Expectations add with no condition at all.
How do indicator variables turn counting into adding?
An indicator variable for an event A is 1 if A happens and 0 if it does not. Its expected value is exactly the probability of A: E(1_A) = P(A).
So when a question asks "how many, on average?", follow three steps:
Break the count into yes-or-no events, one for each place something could happen.
Write the count as a sum of indicators: X = I1 + I2 + ... + In.
Find P(each event) and add them up. That sum is E[X].
You never need the distribution of X. If you have met the binomial mean, this is exactly why it comes out as np; we show that argument in why the binomial mean is np and the variance npq.
How many cards stay in place after a shuffle?
Number n cards 1 to n and shuffle them so that every order is equally likely. How many cards, on average, end up in their original position?
Let Ii be 1 if card i lands in position i. Card i is equally likely to be in any of the n positions, so P(Ii = 1) = 1/n. There are n indicators, so the expected count is n x 1/n = 1.
These indicators are far from independent: if all but one card are in place, the last one must be too. Linearity does not care: the answer is 1 for 3 cards or a million, as the rencontres numbers entry confirms.
What is the expected number of runs in coin tosses?
A run is a maximal block of identical results. The sequence HHTHTTTHHT has six runs: HH, T, H, TTT, HH, T.
Count runs by counting switches. Every run after the first begins where a toss differs from the one before it, so runs = 1 + (number of switches). For n tosses there are n - 1 gaps between neighbours; let Ik be 1 if toss k + 1 differs from toss k.
With a fair coin, each gap is a switch with probability 1/2, so E[runs] = 1 + (n - 1)/2 = (n + 1)/2. Ten tosses give 5.5 runs on average.
Now make it harder: a coin with P(heads) = p. A gap is a switch if it reads HT or TH, which has probability 2p(1 - p). Neighbouring gaps share a toss, yet you can still add: E[runs] = 1 + 2(n - 1)p(1 - p). A biased coin gives fewer runs on average, because long streaks become more likely.
How many packets to collect every sticker?
Say each biscuit packet holds one of 6 cricket stickers, all equally likely. How many packets do you expect to buy to get all six? This is the classic coupon collector's problem.
Split the wait into stages. Once you have k different stickers, a new packet brings a new one with probability (6 - k)/6. Waiting for an event of probability p takes 1/p tries on average, which we derive in expected tosses until the first head. So stage k takes 6/(6 - k) packets, and linearity lets you add the stages:
6/6 + 6/5 + 6/4 + 6/3 + 6/2 + 6/1 = 6 x (1 + 1/2 + 1/3 + 1/4 + 1/5 + 1/6) = 14.7 packets.
In general, collecting n equally likely items takes n x Hn draws on average, where Hn is the n-th harmonic number; the coupon collector entry notes that for 50 items this is about 225 draws. The last sticker alone takes 6 packets on average.
When should you reach for this method?
Check these before building a probability table:
The question asks for an expected number, average count or mean of a sum.
The count splits into yes-or-no events at positions, pairs, gaps or stages.
Each single event has an easy probability, even if events affect each other.
If the question asks for a probability or a variance instead, linearity alone will not finish it. For expectation with payoffs, see how to check whether a dice game is fair.
To practise, take any "expected number of..." problem in the Fermi Problem Library, where a step-by-step solver explains the reasoning, and write the indicators down before you look. If the idea of a random variable itself feels shaky, the lesson on it in the Fermi Concept Library is the place to start.



