Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools

How to Find an Expected Count with Indicator Variables

Many random variables are counts: how many sixes, how many matches, how many distinct values. Split the count into one 0-1 variable per possible event. Each indicator has mean equal to its probability, and the means add even when the events are dependent.

Recognize the task

The question asks for the expected number of something: matches, fixed points, empty boxes, distinct values, successes in dependent trials. The full distribution of the count is messy, but each single event has an easy probability. Test: can you write X=I1+I2+⋯+InX = I_1 + I_2 + \dots + I_n with each IkI_k equal to 11 or 00? Then you do not need the pmf of XX.
Indicators are defined in the indicator random variables lesson.

Steps

StepOn the expected number of people who get their own hat back, 5 hats returned at random
1Define one indicator per event you are counting. Let Ik=1I_k = 1 if event AkA_k happens and 00 otherwise (indicator definition).Ik=1I_k = 1 if person kk gets their own hat, k=1,…,5k = 1, \dots, 5
2Write the count as their sum. Each occurrence adds exactly 11 to the total.X=I1+I2+I3+I4+I5X = I_1 + I_2 + I_3 + I_4 + I_5
3Find the mean of one indicator. E[Ik]=1⋅P(Ak)+0=P(Ak)E[I_k] = 1 \cdot P(A_k) + 0 = P(A_k) (expectation of an indicator).E[Ik]=P(own hat)=15E[I_k] = P(\text{own hat}) = \frac{1}{5}
4Add the means. Linearity holds without independence, so the dependence between the hats does not matter.Linearity of expectation ↗E[X]=5⋅15=1E[X] = 5 \cdot \frac{1}{5} = 1

Worked examples

Example 1 · sixes in 12 rolls

independent
Ik=1I_k = 1 if roll kk is a six
one indicator per roll
E[Ik]=16E[I_k] = \frac{1}{6}
probability of a six
E[X]=12⋅16=2E[X] = 12 \cdot \frac{1}{6} = 2
add 12 equal means

Example 2 · hats returned at random

dependent
nn people, Ik=1I_k = 1 if person kk gets their own hat
E[Ik]=1nE[I_k] = \frac{1}{n}
any hat equally likely
E[X]=n⋅1n=1E[X] = n \cdot \frac{1}{n} = 1
same answer for every nn

Example 3 · distinct faces in 6 rolls

complement inside
If=1I_f = 1 if face ff appears at least once, f=1,…,6f = 1, \dots, 6
count faces, not rolls
E[If]=1−(56)6E[I_f] = 1 - \left(\frac{5}{6}\right)^6
complement of never appearing
E[X]=6(1−(56)6)=310317776≈3.9906E[X] = 6\left(1 - \left(\frac{5}{6}\right)^6\right) = \frac{31031}{7776} \approx 3.9906
add six equal means
Simulate the dice counts in the dice roll tool.

See it happen

Think of each indicator as a light that is on (11) or off (00). The count is the number of lights on. On average, light kk is on a fraction P(Ak)P(A_k) of the time, so the average number of lights on is the sum of those fractions. Whether the lights are wired together does not change any single light's average, which is why dependence never enters the expected count.

Common mistakes

Thinking dependence breaks the method

✗ hats are dependent, so E[X]≠∑E[Ik]E[X] \neq \sum E[I_k]
✓ linearity needs no independence: E[X]=5⋅15=1E[X] = 5 \cdot \frac{1}{5} = 1 (linearity and indicators)

Using the same shortcut for the variance

✗ Var⁡(X)=∑Var⁡(Ik)\operatorname{Var}(X) = \sum \operatorname{Var}(I_k) for the hats
✓ dependent indicators need covariance terms: Var⁡(X)=∑Var⁡(Ik)+2∑j<kCov⁡(Ij,Ik)\operatorname{Var}(X) = \sum \operatorname{Var}(I_k) + 2\sum_{j<k} \operatorname{Cov}(I_j, I_k)
Each single indicator has Var⁡(I)=p(1−p)\operatorname{Var}(I) = p(1 - p) (variance of an indicator).

Indicators for the wrong events

✗ distinct faces: one indicator per roll, E[X]=6E[X] = 6
✓ one indicator per face, "face appears": E[X]≈3.9906E[X] \approx 3.9906