Indicator Random Variables
A random variable that is 1 when an event happens and 0 when it doesn't. Its expectation is just the event's probability, which turns hard counting problems into simple addition.
Prerequisites: Expected Value
An indicator random variable is the simplest object in probability: a switch that reads when some event happens and when it doesn't. Write for the indicator of an event . If a fair coin lands heads, the heads-indicator is ; if not, it's . That's the whole definition. What makes this humble switch one of the most powerful tools in a quant's kit is a single fact and a single rule.
The fact is that the average of a / switch is just the fraction of the time it's on:
In words: the expected value of an indicator is the probability of the event it's watching. Expectation and probability, usually thought of as separate ideas, are the same thing here.
The rule is linearity of expectation: the expected value of a sum is the sum of the expected values, whether or not the pieces are independent. Put the fact and the rule together and you get the counting trick that solves an astonishing range of problems. To count "how many of these events happen," write the count as a sum of indicators, one per event, and add up their probabilities:
, and any count is a sum of indicators. So the expected number of events that happen is just the sum of their probabilities — no messy distribution, no independence needed.
Worked example: the hat-check problem
Here's the classic that shows why indicators feel like magic. people check their hats at a party, and a careless attendant returns the hats in a completely random order. How many people, on average, get their own hat back?
Let be the indicator that person receives their own hat. Any one hat is equally likely to land on any of the people, so , which means . The total number of matches is , so by linearity
On average exactly one person gets their own hat back, whether there are 5 people or 5 million. The indicators here are not independent (if everyone else got their hat, the last person must too), but linearity doesn't care, and we never had to touch the tangled distribution of .
Variance is where dependence bites
Linearity handles the mean for free, but the variance of a sum of indicators is not the sum of the variances unless the events are independent. For a single indicator with ,
and for a sum you must add in every pairwise covariance, . So the mean of a count is easy; its spread requires you to know how the events overlap.
Whenever a problem asks for the expected number of something — matches, records, empty bins, collisions, fixed points — don't fight the distribution. Break the count into one indicator per item, write down each item's probability, and add. It works even when the items are dependent.
Linearity gives the mean for free, but the variance of a sum of indicators is not the sum of the variances unless the events are independent. You have to add every pairwise covariance , which is exactly where dependence sneaks back in.
Where it fits
Indicators are the bridge from probability to counting, and they underpin proofs of the The Law of Large Numbers, the second-moment method, and countless combinatorics brainteasers. The moment an interview question starts with "what is the expected number of…", reach for an indicator sum first.
Related concepts
Practice in interviews
Further reading
- Blitzstein & Hwang, Introduction to Probability, ch. 4
- Ross, A First Course in Probability