From Events to Indicators
An event has a probability, while a count of how many events occur is a random variable. Indicator variables connect these two viewpoints: an event's indicator is \(1\) when the event occurs and \(0\) otherwise, so its expectation is exactly the event's probability. Adding indicators then turns a count into a sum, making expected counts accessible through linearity of expectation.
Work on a probability space \((\Omega,\mathcal{F},\mathbb{P})\). For an event \(A\in\mathcal{F}\), define its indicator variable by \(\mathbf{1}_A(\omega)=1\) if \(\omega\in A\), and \(\mathbf{1}_A(\omega)=0\) if \(\omega\notin A\). It takes only the values \(0\) and \(1\), and is a random variable because \(A\) is an event.
Proof. The indicator has probability \(\mathbb{P}(A)\) of being \(1\) and probability \(1-\mathbb{P}(A)\) of being \(0\). Therefore its expectation, computed from its probability mass function, is \(1\cdot\mathbb{P}(A)+0\cdot(1-\mathbb{P}(A))=\mathbb{P}(A)\). This also covers \(\mathbb{P}(A)=0\) and \(\mathbb{P}(A)=1\). \(\square\)
For a finite collection of events \(A_1,\ldots,A_m\), the number that occur is the random variable \(N=\sum_{r=1}^m\mathbf{1}_{A_r}\). This identity holds outcome by outcome: each event that occurs contributes one to the sum, and each event that does not occur contributes zero. Linearity of expectation therefore gives a useful formula.
Proof. Each indicator is bounded, so each has a finite expectation. By linearity of expectation for a finite sum and the proposition, \(\mathbb{E}[N]=\mathbb{E}[\sum_{r=1}^m\mathbf{1}_{A_r}]=\sum_{r=1}^m\mathbb{E}[\mathbf{1}_{A_r}]=\sum_{r=1}^m\mathbb{P}(A_r)\). The argument uses no joint-probability or independence assumption, so the events may overlap or be dependent. \(\square\)
The theorem is especially useful when a count has many possible values but the probability that any particular item is counted is simple. It does not say that the count's entire distribution is determined by the individual event probabilities: those probabilities alone do not describe how the events overlap. The examples below use direct counting to find each event probability and, where useful, separately check the expected count.
Worked Example: Marked Items in a Sample Without Replacement
There are eight distinct items, three marked and five unmarked. A subset of three items is chosen uniformly from all three-item subsets. Find the expected number \(N\) of marked items selected, then check the result using the distribution of \(N\).
The sample space consists of the \(\binom{8}{3}=56\) equally likely subsets. For each of the three marked items, let \(A_r\) be the event that item \(r\) is selected, for \(r=1,2,3\). The count is \(N=\mathbf{1}_{A_1}+\mathbf{1}_{A_2}+\mathbf{1}_{A_3}\). For any one marked item, the number of subsets containing it is \(\binom{7}{2}=21\), so \(\mathbb{P}(A_r)=21/56=3/8\). Thus the theorem gives \(\mathbb{E}[N]=3(3/8)=9/8\).
Check from the count distribution. For \(N=k\), choose \(k\) of the three marked items and \(3-k\) of the five unmarked items. The counts for \(k=0,1,2,3\) are respectively \(\binom{3}{0}\binom{5}{3}=10\), \(\binom{3}{1}\binom{5}{2}=30\), \(\binom{3}{2}\binom{5}{1}=15\), and \(\binom{3}{3}\binom{5}{0}=1\). These sum to \(10+30+15+1=56\), as required. Consequently, \(\mathbb{E}[N]=(0\cdot10+1\cdot30+2\cdot15+3\cdot1)/56=63/56=9/8\), agreeing with the indicator calculation.
Counting Occupied Boxes
An occupancy problem asks how many boxes receive at least one object. It is often simpler to ask, box by box, whether that box is occupied than to list every possible occupancy pattern. When the objects' assignments are dependent, the indicator-sum identity still applies; each probability must simply be calculated from the model.
Worked Example: Four Balls in Three Boxes
Four labeled balls are assigned independently and uniformly to three labeled boxes. Find the expected number \(K\) of occupied boxes, and verify it by counting assignments according to their number of occupied boxes.
Here \(\Omega=\{1,2,3\}^4\), with all \(3^4=81\) assignments equally likely. For each box \(j\in\{1,2,3\}\), let \(A_j\) be the event that box \(j\) is occupied. There are \(2^4=16\) assignments in which all four balls avoid a specified box, since each ball can go to either of the other two boxes. Therefore \(\mathbb{P}(A_j)=1-16/81=65/81\), and \(K=\sum_{j=1}^3\mathbf{1}_{A_j}\). It follows that \(\mathbb{E}[K]=3(65/81)=195/81=65/27\).
Check by counting assignments. Exactly one box is occupied in \(3\) assignments, one for each choice of that box. For exactly two occupied boxes, choose the empty box in \(3\) ways. For each such choice, there are \(2^4=16\) assignments to the two remaining boxes, but \(2\) put every ball in just one box; hence there are \(3(16-2)=42\) assignments with exactly two occupied boxes. The remaining \(81-3-42=36\) assignments occupy all three boxes. Thus the expected number is \((1\cdot3+2\cdot42+3\cdot36)/81=(3+84+108)/81=195/81=65/27\), which matches the indicator result.
The occupancy calculation illustrates why the indicator method can save work. The expected count required only the probability that one specified box is occupied, multiplied by the three boxes. The distribution check required a separate classification of all 81 assignments. Neither calculation treats the box-occupancy events as independent; indeed, their joint behavior is constrained because only four balls are assigned.
Counts and the Probability of at Least One Event
Indicators also give a basic bound on the probability that at least one event occurs. For a finite family \(A_1,\ldots,A_m\), the indicator of the union is at most the sum of the individual indicators: if none occur, both sides are zero; if at least one occurs, the right side is at least one. Taking expectations proves the union bound.
Proof. For every \(\omega\in\Omega\), \(\mathbf{1}_{\cup_{r=1}^m A_r}(\omega)\leq\sum_{r=1}^m\mathbf{1}_{A_r}(\omega)\): the left side is zero if no event occurs and is one otherwise, while the right side counts the events that occur. Taking expectations and applying the indicator proposition and linearity gives the inequality. If the events are pairwise disjoint, at most one indicator on the right is nonzero at any outcome, so the two sides of the pointwise inequality are equal; their expectations are equal as well. \(\square\)
The distinction between an expected count and a probability of at least one occurrence matters. If \(N=\sum_r\mathbf{1}_{A_r}\), then \(\mathbb{E}[N]\) counts all occurrences, whereas \(\mathbb{P}(N\geq1)\) counts whether there is any occurrence at all. These quantities need not agree, because one outcome can contribute more than one to \(N\).
Worked Example: Fixed Points in a Random Permutation
Choose a permutation of \(\{1,2,3,4\}\) uniformly from its \(4!=24\) permutations. A fixed point is an index \(i\) whose image is \(i\). Find the expected number \(N\) of fixed points, and compare it with the probability of at least one fixed point.
For each \(i\in\{1,2,3,4\}\), let \(A_i\) be the event that \(i\) is fixed. There are \(3!=6\) permutations fixing a specified \(i\), so \(\mathbb{P}(A_i)=6/24=1/4\). The count is \(N=\sum_{i=1}^4\mathbf{1}_{A_i}\), giving \(\mathbb{E}[N]=4(1/4)=1\).
To calculate \(\mathbb{P}(N\geq1)\), count permutations with at least one fixed point. There are \(9\) permutations with none: inclusion and exclusion over the four fixed-point events gives \(24-4(6)+6(2)-4(1)+1=9\). Here the terms use the facts that fixing two specified indices leaves \(2!=2\) permutations, fixing three leaves \(1!=1\), and fixing all four leaves \(0!=1\). Therefore \(24-9=15\) permutations have at least one fixed point, and \(\mathbb{P}(N\geq1)=15/24=5/8\). In particular, \(\mathbb{E}[N]=1\) is not \(\mathbb{P}(N\geq1)=5/8\).
Check by the full count distribution. There are \(9\) permutations with zero fixed points. With exactly one fixed point, choose its index in \(4\) ways; the other three indices must form a permutation with no fixed points, and there are \(3!-3(2!)+3(1!)-1=2\) such permutations. This gives \(4(2)=8\). With exactly two fixed points, choose their indices in \(\binom{4}{2}=6\) ways; the remaining two must swap, giving \(6\) permutations. Exactly three fixed points is impossible, because the remaining index must then also be fixed. Exactly four fixed points occurs in \(1\) permutation. The counts \(9+8+6+0+1=24\) check the sample-space total, and the mean is \((0\cdot9+1\cdot8+2\cdot6+3\cdot0+4\cdot1)/24=24/24=1\).
Common Mistake and Practical Use
Common mistake: treating an expected count as a probability. In the permutation example, writing \(\mathbb{P}(N\geq1)=\mathbb{E}[N]=1\) is wrong: a probability cannot exceed \(1\), and the direct count gives \(15/24=5/8\). The indicator calculation \(\mathbb{E}[N]=\sum_{i=1}^4\mathbb{P}(A_i)=1\) counts every fixed point, including multiple fixed points in the same permutation. To find the probability of at least one, use the union event or count the outcomes in it.
For a finite collection of objects, the practical steps are:
- Define one event for each object that may be counted.
- Write the count as the sum of those event indicators.
- Calculate each event probability under the stated sampling or assignment model.
- Add the probabilities. Do not assume independence is needed for this expectation calculation.
- If the question asks for the probability of at least one occurrence, calculate the union probability instead; the sum of probabilities is generally only an upper bound.
The indicator method is valuable precisely because it separates the definition of a count from the dependence among its components. Dependence can strongly affect the distribution of a count, but for a finite sum it does not alter the rule that its expectation is the sum of the individual event probabilities.
Check Your Understanding
For each question, identify the relevant indicator events before calculating.
- A fair coin is tossed four times. Let \(N\) count the heads. Define \(N\) as a sum of indicators and find \(\mathbb{E}[N]\).
- Five distinct objects include two marked objects. A uniformly chosen subset of size two is selected. What is the expected number of marked objects selected?
- In the four-ball, three-box model, what is the probability that a specified box is empty? How does that event probability contribute to the expected number of occupied boxes?
- For events \(A_1,A_2,A_3\), explain why \(\mathbb{E}[\mathbf{1}_{A_1}+\mathbf{1}_{A_2}+\mathbf{1}_{A_3}]\) is the expected number of events that occur even if the events are dependent.
- Give a reason why \(\mathbb{E}[N]\) need not equal \(\mathbb{P}(N\geq1)\) for a nonnegative integer count \(N\).