Indicator variables can often be used to find an expected value when doing the calculation directly from the definition would be quite difficult. This post will look at a couple of examples and give references to several more.
One of the classic examples of the use of indicator variables is to find the expected number of fixed points in a permutation on elements. (Since I’ve been posting on problems related to the number of fixed points in a permutation lately, it seems appropriate to continue this trend.)
For a given permutation , define the indicator variable such that
Then, for any permutation , . By linearity of expectation, . But . Thus we have .
Therefore the expected number of fixed points in a permutation is, perhaps surprisingly, 1, regardless of the size of the permutation! Obtaining this via the definition would require first counting the number of permutations with exactly fixed points. This could be done, but it would be much more complicated than the simple calculation here.
There are plenty of other examples. I’ll describe a second (classic) one and then give references to some others.
Suppose you are tossing balls into bins. Each ball is equally likely to land in each bin, and the ball tosses are independent. What’s the expected number of bins that contain exactly balls?
Then is the probability that bin contains exactly balls. This is (Choose which of the balls will go into bin , then choose which of the other bins will hold the remaining balls, divided by the total number of ways to distribute balls among bins.)
Thus, if we denote the number the number of bins that contain exactly balls by , we have
See also Section 7.2 of Sheldon Ross’s A First Course in Probability  or one of the following math.SE questions:
- Dinesh’s answer to “How many bins do random numbers fill?”
- Byron Schmuland’s answer to “Find the expectation.”
- joriki’s answer to “Expectation of the cardinality of the intersection of two subsets.” (I particularly like this one. It hadn’t occurred to me at first to use indicator variables.)
- My answer to “Expected number of neighbors.”
Here are two more complicated examples.
- My answer to “Who has the upper hand in a generalized game of Risk?” This question asks for the expected number of casualties suffered by the attacker in a generalized game of Risk. The probabilities associated with the indicator variables do not come out as nicely as in the other examples I’ve given, and the resulting expectation is a quadruple sum. Still, I’m not sure how one would find the requested expected value without using indicator variables.
- My answer to “How to calculate the expected number of distinct items when drawing pairs?” This example is different because the indicator variables can take on the values 0, 1, or 2. That makes the analysis more complicated than in most of the other examples I’ve given, but the use of indicator variables still simplifies the calculation on this problem considerably from what it would be otherwise.
1. Sheldon M. Ross, A First Course in Probability, 7th edition, Prentice Hall, 2005.