Indicator Variables
Write a count as a sum of 0/1 indicators to turn combinatorial counting problems into simple probability calculations.
1. The idea
An indicator variable takes the value 1 if event occurs and 0 otherwise, so . Many counting quantities — fixed points, matches, collisions, occupied boxes — are naturally sums of such indicators.
The power of this trick is that requires only understanding a single event in isolation, even when the individual indicators are highly dependent on each other. Linearity then adds them up for free.
This is the standard way to compute expected counts in permutations (fixed points), balls-in-bins problems (occupied boxes), and matching or collision problems — situations where the full joint distribution of the count is complicated or unnecessary.
2. Why it matters
Indicator variables are the most frequently tested combinatorial expectation trick in quant interviews, appearing in fixed-point, hashing-collision, and occupancy problems.
3. Core mathematics
Indicator expectation
Expected count
Random permutation fixed points
4. How to recognize it
Think of this when…
- The question asks for the expected number of matches, fixed points, or coincidences
- You're counting occupied bins/boxes after randomly distributing items
- Individual events overlap or are dependent, ruling out a simple product formula
- The quantity of interest is a sum of yes/no outcomes across many positions or items
5. Worked example
Worked example
A random permutation of is chosen. Find the expected number of fixed points (positions where the permutation maps ).
- 1
Let if position is a fixed point, else 0. The total fixed points is .
- 2
By symmetry, each position is equally likely to be any value, so .
- 3
Apply linearity — the are dependent, but that does not matter.
- Answer: , independent of
6. Common mistakes
- Trying to find the full distribution of the count instead of just its expectation
- Assuming indicators must be independent to sum their expectations
- Miscounting the number of indicator terms (e.g., off-by-one in the number of adjacent pairs)
- Forgetting that requires to be exactly 0/1, not a general count
7. Quick check
balls are thrown independently into boxes. What is the expected number of empty boxes?
In a random shuffle of a deck, what is the expected number of cards in their original position?
8. Practice
10 QuantSolve questions use this concept.
Practice this concept9. Related methods
Create a free account to save lesson progress.
Recommended next lessonConditional Expectation →