Tutorials › Introduction to Statistics › Indicator Variables and Expected Counts

Random Variables and Expected Value · Tutorial 356 of 996

Indicator Variables and Expected Counts

Represent events with indicator variables and use their probabilities to calculate expected counts, without requiring independence.

Intermediate 9 min read

What You'll Learn

  • Define a zero-one indicator for an event
  • Derive an indicator’s expectation from the event probability
  • Express a count as a sum of indicators
  • Calculate expected counts when event probabilities differ
  • Explain why independence is not needed for the expected-count formula
  • Distinguish an expected count from a guaranteed or most likely count

Why Represent Events with Indicators?

Many questions ask not whether one event occurs, but how many times it occurs. How many patients in a group might experience a side effect? How many of several components might fail? A useful way to answer such questions is to turn each event into a simple random variable that records only whether it happens. These variables are called indicators.

An indicator takes only two values: 1 when its event occurs and 0 otherwise. Its expected value is therefore especially simple: it equals the probability of the event. When several events are counted, adding their indicators gives the count. The expected count can then be found by adding the individual event probabilities. Importantly, this calculation does not require the events to be independent.

Definition: For an event \(A\), its indicator variable \(I_A\) is defined by \(I_A=1\) if \(A\) occurs and \(I_A=0\) if \(A\) does not occur. Its expected value is \[ E[I_A]=P(A). \] For events \(A_1,\ldots,A_n\), the number \(C\) of events that occur is \[ C=I_{A_1}+\cdots+I_{A_n}, \] and its expected value is \[ E[C]=\sum_{i=1}^{n}P(A_i). \]

Why an Indicator’s Expectation Is a Probability

An expected value is a probability-weighted average of a random variable’s possible values. An indicator has just two possible values: 1 and 0. The value 1 has probability \(P(A)\), while the value 0 has probability \(1-P(A)\). Thus the expectation is

$$ E[I_A]=1\cdot P(A)+0\cdot(1-P(A))=P(A). $$

The zero-valued outcome contributes nothing to the average, and the one-valued outcome contributes its probability. This identity is useful because it changes a question about the expected value of a random variable into a question about the probability of an event.

Worked Example: From a Failure Probability to an Expected Count

Suppose a hypothetical batch contains 60 devices. For each device, the probability of failure during a specified test is 0.04. Let \(I_i\) equal 1 if device \(i\) fails and 0 otherwise. Find the expected number of failures.

For any one device, the indicator’s expectation equals its failure probability:

$$ E[I_i]=1(0.04)+0(0.96)=0.04. $$

The total number of failures is \(C=I_1+\cdots+I_{60}\). Therefore, add the 60 failure probabilities:

$$ E[C]=60(0.04)=2.4 \text{ failures}. $$

The expected count is 2.4 failures. This does not mean that a particular batch can contain 2.4 failed devices; its actual count must be a whole number. It means that 2.4 is the probability-weighted average count across repetitions of the same process. The calculation uses the marginal failure probability for each device; it does not require device failures to be independent.

Counting Several Events

To count how many of \(n\) events occur, make one indicator for each event. If \(A_i\) is the event that the \(i\)th specified outcome occurs, then \(I_{A_i}\) contributes exactly one to the count when that event occurs, and zero otherwise. Summing the indicators therefore counts the occurrences.

The expected count adds the probabilities of those events. They need not have the same probability: each event contributes its own probability. This is useful when, for example, different individuals have different risks of an outcome.

Worked Example: Different Probabilities for Different People

In a hypothetical training program, four participants have probabilities of completing an optional exercise of 0.90, 0.80, 0.70, and 0.60. Find the expected number who complete it. No assumption about whether their completion events are independent is made.

Let \(I_i=1\) if participant \(i\) completes the exercise and \(I_i=0\) otherwise. Then the expected number of completions is the sum of the four individual probabilities:

$$ E[C]=0.90+0.80+0.70+0.60=3.00 \text{ participants}. $$

So the expected count is 3.00 participants. This result does not say that exactly three participants will complete the exercise, nor does it say that three is the most likely count. It is the average count implied by the four event probabilities. Whether one participant’s completion is related to another’s does not change this expected count.

Why Independence Is Not Required

The count formula can be justified directly by the definition of expectation. For a finite outcome space, write \(\omega\) for one possible outcome of the whole process and \(P(\omega)\) for its probability. On outcome \(\omega\), the count \(C\) equals the sum of the indicators’ values. Consequently,

$$ \begin{aligned} E[C] &=\sum_{\omega}P(\omega)C(\omega)\\ &=\sum_{\omega}P(\omega)\sum_{i=1}^{n}I_{A_i}(\omega)\\ &=\sum_{i=1}^{n}\sum_{\omega}P(\omega)I_{A_i}(\omega)\\ &=\sum_{i=1}^{n}P(A_i). \end{aligned} $$

The last equality holds because \(I_{A_i}(\omega)\) is 1 precisely for outcomes in \(A_i\), and 0 for all other outcomes. Thus the inner sum includes exactly the probabilities of outcomes in \(A_i\), which add to \(P(A_i)\). At no point does the argument require joint probabilities to factor into products of individual probabilities. Independence is not part of the assumptions.

This derivation is specific to counting events through their indicators. It establishes the expected-count result directly; it does not require calculating the full probability distribution of the count. That distinction matters because dependence can change the distribution of a count even when the expected count stays the same.

Worked Example: Counting Marked Items Without Replacement

A hypothetical container holds five cards, two marked and three unmarked. Two cards are drawn without replacement. Find the expected number of marked cards drawn, using indicators, and verify the result from the possible counts.

Let \(I_1=1\) if the first draw is marked and \(I_1=0\) otherwise; define \(I_2\) in the same way for the second draw. Each draw position has probability \(2/5\) of receiving a marked card. Therefore,

$$ E[C]=E[I_1]+E[I_2]=\frac{2}{5}+\frac{2}{5}=\frac{4}{5}=0.8000 \text{ marked cards}. $$

The draws are dependent: once the first card is known, the composition of the remaining cards has changed. The expected-count calculation nevertheless works because it uses each draw position’s probability of being marked, not an independence assumption.

To verify by listing the possible counts, there are \(\binom{5}{2}=10\) equally likely pairs of cards. The probability of drawing zero marked cards is \(\binom{3}{2}/10=3/10\); the probability of drawing one is \(2\cdot3/10=6/10\); and the probability of drawing two is \(\binom{2}{2}/10=1/10\). The expectation from this distribution is

$$ E[C]=0\left(\frac{3}{10}\right)+1\left(\frac{6}{10}\right)+2\left(\frac{1}{10}\right)=0.8000 \text{ marked cards}. $$

Both approaches give the same expected count. The indicator method reaches it without first finding the entire distribution of \(C\).

What the Expected Count Does—and Does Not—Tell You

An expected count summarizes an average, not a promise about one particular set of outcomes. It can be fractional even though the actual count is an integer. It also does not, on its own, identify which count is most likely or how much the count varies. Those questions require information about the distribution of the count.

Dependence can affect that distribution. For instance, two events that always occur together can have the same individual probabilities as two events that can never occur together, while producing very different possible counts. Yet if each event has probability \(1/2\), the expected count in either case is \(1/2+1/2=1\). The expected count is determined by the individual probabilities; the pattern of joint occurrence is not needed for this particular calculation.

Common Mistake: Assuming Independence Is Needed

A common mistake is to say, “I cannot add the probabilities because the events are dependent.” That reasoning confuses the expected count with the probability that a particular combination of events occurs. Calculating a joint probability may require information about dependence, but the expected count of occurrences is found by summing the marginal event probabilities:

$$ E[C]=P(A_1)+\cdots+P(A_n). $$

The correction is to define an indicator for each event, express the count as their sum, and add the individual probabilities. Do not multiply probabilities as if the events were independent unless independence has actually been established and multiplication is needed for the question being asked.

Key takeaway: An event’s zero-one indicator has expectation equal to the event’s probability. The count of events that occur is the sum of their indicators, so its expected value is the sum of their probabilities, whether or not the events are independent.

Check Your Understanding

Answer each question using indicators where useful.

  1. An event has probability 0.18. Define its indicator and find the indicator’s expected value.
  2. Three components have probabilities of failure 0.01, 0.03, and 0.05. Find the expected number of failures. Is the result affected by dependence among the failures?
  3. Why can an expected count be 2.4 even though an actual count must be a whole number?
  4. Two events each have probability 0.40. What is the expected number of events that occur? What additional information would be needed to determine the full distribution of that count?
  5. In a random draw without replacement, explain why the events “the first draw is marked” and “the second draw is marked” can be dependent while the indicator method still gives the expected number of marked draws.