the indicator-variable trick for expectations of counts
Many counting questions in probability ask 'how many, on average?' — how many people share a birthday, how many letters land in the right envelope, how many empty boxes after throwing balls. Computing the full distribution of such a count is often a nightmare. The indicator-variable trick sidesteps the whole distribution and gets the expected count almost for free.
An indicator variable is the simplest random variable there is: a 1/0 switch that equals 1 if some event happens and 0 if it does not. Its expectation is beautifully clean — E[indicator of A] = 1 P(A) + 0 P(not A) = P(A). The expected value of an indicator is just the probability of its event. The trick: write your count as a sum of indicators, one per thing that might be counted. Then by linearity of expectation, the expected count is simply the sum of those probabilities. In plain steps: (1) for each item i, define I_i = 1 if item i counts, else 0; (2) the total count is X = sum of I_i; (3) E[X] = sum of E[I_i] = sum of P(item i counts).
The magic is that linearity of expectation needs no independence, so the indicators may be tangled together in complicated ways and it does not matter at all — you never have to untangle them. Want the expected number of fixed points of a random permutation of n items? Each position has probability 1/n of being fixed, there are n positions, so the expected number of fixed points is n times 1/n = 1, regardless of n, even though the events 'position i is fixed' are dependent. This one idea cracks the birthday problem, the matching (hat-check) problem, and countless others in a single line.
Throw 10 balls independently into 10 boxes. Expected number of empty boxes? For each box, P(empty) = (9/10)^10 ≈ 0.349. Let I_k indicate box k empty; X = sum of I_k, so E[X] = 10 (0.349) ≈ 3.49 empty boxes — found without ever computing the distribution of X.
Write the count as a sum of 1/0 indicators; the expected count is the sum of the probabilities.
The trick gives the EXPECTED count effortlessly, but the variance of the count does require the dependence (covariances) between indicators — linearity is free only for the mean.