Tutorials › Exam P - Probability › Covariance of Counts Built From Shared Indicators

Exam P · Covariance and Correlation · Tutorial 758 of 915

Covariance of Counts Built From Shared Indicators

Expressing counts as sums of indicators makes it possible to calculate their covariance by tracking shared events and the dependence between event terms.

Intermediate 10 min read

What You'll Learn

  • Represent an event count as a sum of indicator random variables.
  • Derive the covariance formula for two sums of indicators.
  • Identify contributions from indicators that appear in both counts.
  • Handle related but nonidentical events on the same unit.
  • Check whether independence across units justifies simplifying the calculation.

Why Shared Events Matter

Two counts can be related because they include some of the same events. For example, two monitoring summaries might count alerts from overlapping sets of locations. An alert in a shared location contributes to both counts, so the counts are not automatically independent. Writing each count as a sum of indicator random variables makes the overlap explicit and gives a systematic covariance calculation.

The key is to distinguish two situations. A count may include the same indicator as another count, so that one event term appears in both sums. Or the counts may include different indicators for the same unit, such as two different kinds of event that can occur on one device. In the second situation, the indicators can be dependent even though they are not identical.

Definition: For an event \(A\), its indicator random variable is \(I_A=1\) if \(A\) occurs and \(I_A=0\) otherwise. In particular, \(E[I_A]=P(A)\). If \(X\) counts how many of the events \(A_1,\ldots,A_n\) occur, then \(X=\sum_{i=1}^n I_{A_i}\).

Covariance of Two Counts

Suppose \(X=\sum_{i=1}^m I_{A_i}\) and \(Y=\sum_{j=1}^n I_{B_j}\). The covariance formula for two sums gives the covariance of the counts as a sum over every pair of event terms, one from each count. This is important: the calculation is not limited to indicators with matching subscripts.

Theorem: For finite sums of indicators,
$$ \operatorname{Cov}(X,Y) = \sum_{i=1}^{m}\sum_{j=1}^{n}\operatorname{Cov}(I_{A_i},I_{B_j}) = \sum_{i=1}^{m}\sum_{j=1}^{n} \left[P(A_i\cap B_j)-P(A_i)P(B_j)\right]. $$

The formula requires the event probabilities and intersections to be defined under the same probability model. It does not require the indicators to be independent. Rather, it includes the covariance of each pair, whether that covariance is positive, negative, or zero.

Why the Formula Holds

Covariance measures the expected product of deviations from the means. Because a finite sum of deviations is the sum of the individual deviations, multiplying the two sums produces all cross-pairs. Taking expectations then adds the covariance contribution of each pair.

1
Center each count.
Write \(X-E[X]=\sum_i(I_{A_i}-E[I_{A_i}])\), and write the corresponding expression for \(Y-E[Y]\).
2
Multiply the centered sums.
The product contains one term \((I_{A_i}-E[I_{A_i}])(I_{B_j}-E[I_{B_j}])\) for every pair \((i,j)\).
3
Take expectations.
By linearity of expectation, the expectation of the product is the sum of the expectations of those pair terms. Each expectation is \(\operatorname{Cov}(I_{A_i},I_{B_j})\).
4
Evaluate an indicator pair.
Since \(I_{A_i}I_{B_j}=1\) exactly when \(A_i\cap B_j\) occurs, \(E[I_{A_i}I_{B_j}]=P(A_i\cap B_j)\). Subtracting \(E[I_{A_i}]E[I_{B_j}]\) gives the stated probability difference.

A useful special case occurs when exactly the same indicator appears in both counts. Since \(I_A^2=I_A\),

$$ \operatorname{Cov}(I_A,I_A) = E[I_A^2]-E[I_A]^2 = P(A)-P(A)^2 = P(A)\bigl(1-P(A)\bigr). $$

If all distinct indicators in the combined lists are mutually independent, then every pair of distinct indicators has covariance zero. Only the identical indicators shared by the two counts contribute. In that case, if the shared events are \(A_i\), the covariance is the sum of \(P(A_i)(1-P(A_i))\) over those shared events. This shortcut does not apply when distinct indicators may be dependent.

Worked Example: Two Counts With Shared Alert Indicators

A hypothetical monitoring system records whether each of four zones produces an alert during a shift. Let \(I_k\) be the indicator of an alert in zone \(k\). Assume the four indicators are mutually independent, with probabilities \(P(I_1=1)=0.20\), \(P(I_2=1)=0.40\), \(P(I_3=1)=0.50\), and \(P(I_4=1)=0.10\). Let \(X=I_1+I_2+I_3\) count alerts in the first report and \(Y=I_2+I_3+I_4\) count alerts in the second report. Find \(\operatorname{Cov}(X,Y)\).

Method. Expand the covariance into pairwise terms. Since the indicators are mutually independent, distinct-zone pairs have covariance zero. The indicators \(I_2\) and \(I_3\) occur in both counts, so their self-covariances remain.

The shared indicator \(I_2\) contributes \[ \operatorname{Cov}(I_2,I_2)=0.40(1-0.40)=0.40(0.60)=0.24. \] The shared indicator \(I_3\) contributes \[ \operatorname{Cov}(I_3,I_3)=0.50(1-0.50)=0.50(0.50)=0.25. \] Every other cross-pair uses different independent zones and contributes zero. Therefore, \[ \operatorname{Cov}(X,Y)=0.24+0.25=0.49. \]

Check. The means are \(E[X]=0.20+0.40+0.50=1.10\) and \(E[Y]=0.40+0.50+0.10=1.00\). Expanding \(XY\) and using independence gives \(E[XY]=1.59\), so \(E[XY]-E[X]E[Y]=1.59-(1.10)(1.00)=0.49\), as required. The common mistake avoided here is treating the two reports as independent just because they have different names; both include the same two alert indicators.

Different Event Types on the Same Unit

Not every useful simplification comes from indicators that are identical. Suppose each unit can experience two different event types. Even if units are independent of one another, the two event indicators on a given unit may be dependent. For example, two faults on the same device might occur together more or less often than their marginal probabilities alone would suggest.

If \(A_r\) and \(B_r\) describe two event types on unit \(r\), and different units are independent, then the covariance of the total counts reduces to the sum of the within-unit covariances:

$$ \operatorname{Cov}\left(\sum_{r=1}^{N}I_{A_r},\sum_{r=1}^{N}I_{B_r}\right) = \sum_{r=1}^{N} \left[P(A_r\cap B_r)-P(A_r)P(B_r)\right]. $$

The terms involving different units vanish because of the stated independence assumption. The within-unit term does not vanish unless the event indicators on that unit are independent or happen to have zero covariance.

Worked Example: Two Fault Counts Across Independent Devices

A hypothetical batch contains 8 devices. For each device, let \(A\) be the event of a thermal fault and \(B\) the event of a voltage fault. Assume devices are independent and identically distributed, with \(P(A)=0.20\), \(P(B)=0.30\), and \(P(A\cap B)=0.10\) for one device. Let \(X\) count thermal faults in the batch and \(Y\) count voltage faults. Find their covariance.

For one device, the covariance between its two fault indicators is \[ P(A\cap B)-P(A)P(B)=0.10-(0.20)(0.30)=0.10-0.06=0.04. \]

There are 8 within-device contributions, each equal to \(0.04\). Every cross-device pair has covariance zero because devices are independent. Thus, \[ \operatorname{Cov}(X,Y)=8(0.04)=0.32. \]

Check. The expected counts are \(E[X]=8(0.20)=1.60\) and \(E[Y]=8(0.30)=2.40\), whose product is \(3.84\). For \(E[XY]\), the 8 same-device terms contribute \(8(0.10)=0.80\). The \(8\cdot7=56\) ordered pairs of different devices contribute \(56(0.20)(0.30)=56(0.06)=3.36\). Hence \(E[XY]=0.80+3.36=4.16\), and \(E[XY]-E[X]E[Y]=4.16-3.84=0.32\). A common error is to multiply the within-device covariance by \(8^2\); cross-device covariances are zero, so there are only 8 nonzero terms.

Worked Example: Counts From Overlapping Time Windows

Across six days, let \(I_k\) indicate whether a hypothetical system receives a service request on day \(k\). Assume the six daily indicators are mutually independent. The daily request probabilities are \(0.10, 0.20, 0.25, 0.60, 0.30,\) and \(0.15\), respectively. Let \(X=I_1+I_2+I_3+I_4\) count requests on days 1 through 4, and \(Y=I_3+I_4+I_5+I_6\) count requests on days 3 through 6. Find \(\operatorname{Cov}(X,Y)\).

The shared indicators are \(I_3\) and \(I_4\). Their probabilities are \(0.25\) and \(0.60\), so their covariance contributions are \[ \operatorname{Cov}(I_3,I_3)=0.25(0.75)=0.1875, \qquad \operatorname{Cov}(I_4,I_4)=0.60(0.40)=0.2400. \]

All cross-pairs involving different days have covariance zero under the mutual-independence assumption. Therefore, \[ \operatorname{Cov}(X,Y)=0.1875+0.2400=0.4275. \]

Check. Only days 3 and 4 lie in both windows. The result is positive because a request on either shared day increases both counts. Days 1, 2, 5, and 6 affect only one of the two counts, and their indicators are independent of those in the other window; they add no covariance.

Common Mistakes and a Reliable Procedure

A covariance calculation can be short once the right pairs have been identified. The main risk is simplifying before checking the dependence assumptions. In particular, “different event labels” does not imply independent indicators, and “different counts” does not imply independent random variables.

For example, in the shared-alert example, the incorrect calculation \( \operatorname{Cov}(X,Y)=0 \) treats the reports as independent. The correction is to list the terms in both sums: \(I_2\) and \(I_3\) occur in each, contributing \(0.24+0.25=0.49\). In the device example, by contrast, thermal and voltage faults are different indicators on the same device. Their covariance is \(0.10-(0.20)(0.30)=0.04\), not zero. The joint probability is needed to determine that contribution.

Use the following sequence before applying a shortcut:

  1. Write each count as a sum of event indicators.
  2. Compare the two lists and mark indicators that are identical.
  3. For each remaining pair, decide whether the events are independent or whether their intersection probability is needed.
  4. Sum the pairwise covariance contributions, including zeros only when the model justifies them.
  5. Check the result using \(E[XY]-E[X]E[Y]\), when those expectations are convenient to calculate.
Key takeaway: The covariance of two indicator counts is the sum of all cross-pair covariances. Shared indicators contribute their variances; distinct indicators contribute according to their joint probabilities and dependence. Simplify only after identifying which pairs are independent.

Check Your Understanding

For each problem, express the counts as sums of indicators and identify which pairwise terms can contribute.

  1. Five independent locations have alert indicators. The probability of an alert at location 3 is \(0.40\). Let \(X\) count alerts at locations 1, 2, and 3, and \(Y\) count alerts at locations 3, 4, and 5. Find \(\operatorname{Cov}(X,Y)\). (Answer: \(0.2400\))
  2. For each of 6 independent vehicles, two event types have probabilities \(P(A)=0.25\), \(P(B)=0.40\), and \(P(A\cap B)=0.15\). Let \(X\) and \(Y\) count the two event types across the vehicles. Find \(\operatorname{Cov}(X,Y)\). (Answer: \(0.3000\))
  3. Four mutually independent indicators have success probabilities \(0.10, 0.30, 0.70,\) and \(0.20\). Let \(X=I_1+I_2+I_3\) and \(Y=I_2+I_3+I_4\). Find \(\operatorname{Cov}(X,Y)\). (Answer: \(0.4200\))
  4. Each of 10 independent inspections can find a crack or a leak, but the two findings cannot occur together on one inspection. For one inspection, \(P(\text{crack})=0.10\) and \(P(\text{leak})=0.20\). Let \(X\) and \(Y\) be the total crack and leak counts. Find their covariance. (Answer: \(-0.2000\))
  5. Across 4 independent days, a dispatch indicator \(A\) and a rainfall indicator \(B\) have, for each day, \(P(A)=0.50\), \(P(B)=0.25\), and \(P(A\cap B)=0.20\). Let \(X\) count dispatches and \(Y\) count rainy days. Find \(\operatorname{Cov}(X,Y)\). (Answer: \(0.3000\))
Clinical Biostats