Quant Memo
Foundational

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 11 when some event happens and 00 when it doesn't. Write 1A\mathbf{1}_A for the indicator of an event AA. If a fair coin lands heads, the heads-indicator is 11; if not, it's 00. 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 00/11 switch is just the fraction of the time it's on:

E[1A]=1P(A)+0P(Ac)=P(A).E[\mathbf{1}_A] = 1\cdot P(A) + 0\cdot P(A^c) = P(A).

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:

X=i1AiE[X]=iP(Ai).X = \sum_{i} \mathbf{1}_{A_i} \quad\Longrightarrow\quad E[X] = \sum_i P(A_i).

E[1A]=P(A)E[\mathbf{1}_A] = P(A), 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.

H T H H T H T H 1 0 1 1 0 1 0 1 X = 1 + 0 + 1 + 1 + 0 + 1 + 0 + 1 = 5
Each flip contributes its own indicator, 1 for heads and 0 for tails. This particular outcome sums to 5 heads; the expected count is just the sum of the eight probabilities, 8 × 0.5 = 4.

Worked example: the hat-check problem

Here's the classic that shows why indicators feel like magic. nn people check their hats at a party, and a careless attendant returns the nn hats in a completely random order. How many people, on average, get their own hat back?

Let 1j\mathbf{1}_j be the indicator that person jj receives their own hat. Any one hat is equally likely to land on any of the nn people, so P(person j gets their hat)=1nP(\text{person } j \text{ gets their hat}) = \tfrac{1}{n}, which means E[1j]=1nE[\mathbf{1}_j] = \tfrac{1}{n}. The total number of matches is X=11++1nX = \mathbf{1}_1 + \dots + \mathbf{1}_n, so by linearity

E[X]=j=1n1n=n1n=1.E[X] = \sum_{j=1}^n \frac{1}{n} = n\cdot\frac{1}{n} = 1.

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 XX.

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 p=P(A)p = P(A),

Var(1A)=p(1p),\operatorname{Var}(\mathbf{1}_A) = p(1-p),

and for a sum you must add in every pairwise covariance, Cov(1A,1B)=P(AB)P(A)P(B)\operatorname{Cov}(\mathbf{1}_A, \mathbf{1}_B) = P(A\cap B) - P(A)P(B). 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 P(AB)P(A)P(B)P(A\cap B) - P(A)P(B), 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
ShareTwitterLinkedIn