Tutorials › Statistical Theory I - Probability and Distribution Theory › Conditioning on a Random Count

Conditional Expectation · Tutorial 341 of 994

Conditioning on a Random Count

Use conditioning on the count to calculate random-sum means and variances, including cases where the summands’ conditional distributions depend on that count.

Intermediate 9 min read

What You'll Learn

  • Define a random sum, including the empty sum when the count is zero
  • Derive conditional means and variances of sums of conditionally independent terms
  • Apply the law of total expectation and total variance to random sums
  • Use the independent, identically distributed summand formulas
  • Recognize how count variation and dependence affect a random-sum variance

Why Condition on the Count?

Many totals are built by adding a random number of contributions: claims paid in a period, customers’ purchases, or successes among a random number of trials. The count affects the total in two ways. Even if each contribution has a stable distribution, the number of contributions varies; and, for a fixed count, the contributions themselves vary. Conditioning on the count separates these sources of variation.

Let \(N\) be a nonnegative integer-valued random variable and let \(X_1,X_2,\ldots\) be a sequence of random contributions. The total is the sum of the first \(N\) contributions. We first find its conditional mean and variance when the count is fixed, then average over the possible counts.

Definition: The random sum with count \(N\) and terms \(X_1,X_2,\ldots\) is $$ S_N=\sum_{i=1}^{N}X_i. $$ When \(N=0\), the sum is defined to be \(0\). The terms may be dependent, and their distributions may depend on \(N\); any independence or moment assumptions used in a formula must therefore be stated.

Conditional Moments at a Fixed Count

Suppose that, given \(N=n\), the first \(n\) terms are conditionally independent. Write their conditional means and variances as \(m_{i,n}=E[X_i\mid N=n]\) and \(v_{i,n}=\operatorname{Var}(X_i\mid N=n)\), for \(1\leq i\leq n\). These quantities are needed only for counts \(n\) with \(P(N=n)>0\).

For a fixed \(n\), the sum contains exactly \(n\) terms. Linearity of conditional expectation gives its conditional mean. Conditional independence makes the cross-products of distinct centered terms have conditional expectation zero, so the conditional variance is the sum of the individual conditional variances.

Theorem: Suppose \(N\) is nonnegative integer-valued, each \(X_i\) has a finite second moment conditional on \(N=n\) whenever \(P(N=n)>0\), and \(X_1,\ldots,X_n\) are conditionally independent given \(N=n\). Then $$ E[S_N\mid N=n]=\sum_{i=1}^{n}m_{i,n}, \qquad \operatorname{Var}(S_N\mid N=n)=\sum_{i=1}^{n}v_{i,n}. $$ If \(E|S_N|<\infty\) and \(\operatorname{Var}(S_N)<\infty\), it follows that $$ E[S_N]=E\!\left[\sum_{i=1}^{N}m_{i,N}\right], \qquad \operatorname{Var}(S_N)=E\!\left[\sum_{i=1}^{N}v_{i,N}\right] +\operatorname{Var}\!\left(\sum_{i=1}^{N}m_{i,N}\right). $$

To verify the conditional variance claim, fix an \(n\) with positive probability and subtract the conditional means from the terms. The centered terms have conditional mean zero. When the square of their sum is expanded, conditional independence implies that each cross-product has expectation zero:

$$ \begin{aligned} \operatorname{Var}(S_N\mid N=n) &=E\!\left[\left\{\sum_{i=1}^{n}(X_i-m_{i,n})\right\}^{2}\middle|N=n\right]\\ &=\sum_{i=1}^{n}E[(X_i-m_{i,n})^2\mid N=n]\\ &\quad+2\sum_{1\leq i<j\leq n} E[(X_i-m_{i,n})(X_j-m_{j,n})\mid N=n]\\ &=\sum_{i=1}^{n}v_{i,n}. \end{aligned} $$

The conditional mean follows by linearity, without requiring independence. To obtain the unconditional formulas, apply the law of total expectation to the conditional mean and the law of total variance to the conditional variance and mean. In the latter, the first term is the average variation of the sum at a fixed count; the second is the variation of its conditional mean across counts. This proves the result. \(\square\)

The Common Independent-Summand Formula

A particularly useful case arises when \(N\) is independent of the sequence of summands and the \(X_i\) are identically distributed and independent, with \(E[X_i]=\mu\) and \(\operatorname{Var}(X_i)=\sigma^2<\infty\). Then, for every possible count \(n\), each conditional mean is \(\mu\) and each conditional variance is \(\sigma^2\). The general formulas reduce to the following.

Random-sum formulas: Under the assumptions above, if \(E[N]<\infty\) and \(\operatorname{Var}(N)<\infty\), then $$ E[S_N]=\mu E[N], \qquad \operatorname{Var}(S_N)=\sigma^2 E[N]+\mu^2\operatorname{Var}(N). $$

The variance has two components. The term \(\sigma^2E[N]\) is the average contribution-level variation when the count is fixed. The term \(\mu^2\operatorname{Var}(N)\) accounts for changes in the expected total as the count changes. If the contributions have mean zero, count variation does not add this second term: changing the count changes the expected total by zero.

Worked Example: A Poisson Count of Bernoulli Contributions

Suppose \(N\sim\operatorname{Poisson}(4)\), independently of the contributions, and each \(X_i\) is Bernoulli with success probability \(0.3\). Find the mean and variance of the total number of successes \(S_N\).

For a Bernoulli\((0.3)\) variable, \(\mu=0.3\) and \(\sigma^2=0.3(1-0.3)=0.21\). For a Poisson\((4)\) count, \(E[N]=4\) and \(\operatorname{Var}(N)=4\). Therefore,

$$ E[S_N]=0.3(4)=1.2, \qquad \operatorname{Var}(S_N)=0.21(4)+(0.3)^2(4)=0.84+0.36=1.2. $$

The count’s variability contributes \(0.36\) to the variance; the Bernoulli variability contributes \(0.84\). Both are needed, even though the total happens to have equal mean and variance in this example.

Worked Example: A Binomial Count of Variable Contributions

Let \(N\sim\operatorname{Binomial}(10,0.2)\), independently of the \(X_i\). Each contribution equals \(3\) or \(7\), each with probability \(1/2\). Calculate the mean and variance of \(S_N\).

The contribution mean is \(\mu=(3+7)/2=5\). Its variance is \(\sigma^2=\{(3-5)^2+(7-5)^2\}/2=4\). For this count, \(E[N]=10(0.2)=2\) and \(\operatorname{Var}(N)=10(0.2)(0.8)=1.6\). Substitution gives

$$ E[S_N]=5(2)=10, \qquad \operatorname{Var}(S_N)=4(2)+5^2(1.6)=8+40=48. $$

The large count-variation component, \(40\), reflects that each additional contribution increases the conditional expected total by \(5\). The fixed-count contribution variation is \(8\).

When the Conditional Summand Distribution Changes

Independence of the count and the summands is not required for the conditional formulas. What matters is the conditional distribution given \(N\). If the conditional mean or variance changes with \(N\), use those conditional moments rather than unconditional ones.

For example, suppose that, given \(N=n\), the terms are conditionally independent and identically distributed with conditional mean \(m_n\) and variance \(v_n\). Then the conditional total has mean \(nm_n\) and variance \(nv_n\), giving

$$ E[S_N]=E[Nm_N], \qquad \operatorname{Var}(S_N)=E[Nv_N]+\operatorname{Var}(Nm_N), $$

provided the total has finite mean and variance. The count cannot in general be separated from \(m_N\) or \(v_N\): doing so would incorrectly treat the conditional distribution as unchanged across count values.

Worked Example: Conditional Contributions Depend on the Count

Let \(N\) equal \(1\) or \(2\), each with probability \(1/2\). Given \(N=1\), let the single contribution be \(1\) or \(3\), each with probability \(1/2\). Given \(N=2\), let \(X_1\) and \(X_2\) be conditionally independent, each equal to \(1\) or \(5\), each with probability \(1/2\). Find \(E[S_N]\) and \(\operatorname{Var}(S_N)\).

When \(N=1\), the conditional contribution mean is \(2\) and its variance is \(\{(1-2)^2+(3-2)^2\}/2=1\). Thus \(E[S_N\mid N=1]=2\) and \(\operatorname{Var}(S_N\mid N=1)=1\).

When \(N=2\), each term has conditional mean \(3\) and variance \(\{(1-3)^2+(5-3)^2\}/2=4\). Conditional independence gives \(E[S_N\mid N=2]=2(3)=6\) and \(\operatorname{Var}(S_N\mid N=2)=2(4)=8\). Averaging the conditional means gives

$$ E[S_N]=\tfrac12(2)+\tfrac12(6)=4. $$

The expected conditional variance is \(\tfrac12(1)+\tfrac12(8)=4.5\). The conditional mean is \(2\) or \(6\), each with probability \(1/2\), so its variance is \(\{(2-4)^2+(6-4)^2\}/2=4\). Therefore,

$$ \operatorname{Var}(S_N)=4.5+4=8.5. $$

As a check, the conditional second moments are \(1+2^2=5\) when \(N=1\) and \(8+6^2=44\) when \(N=2\). Hence \(E[S_N^2]=\tfrac12(5)+\tfrac12(44)=24.5\), and \(24.5-4^2=8.5\), as calculated.

Common Mistake: Leaving Out Count Variation

A frequent error is to calculate the variance as \(E[N]\sigma^2\) and stop. That is only the first component under the independent, identically distributed assumptions. For a quick check, let \(N\) be Bernoulli with success probability \(1/2\), and let every contribution be the constant \(2\). Then \(S_N=2N\), so \(E[S_N]=1\) and \(\operatorname{Var}(S_N)=4(1/4)=1\). The incomplete calculation \(E[N]\operatorname{Var}(X_1)\) gives zero because each contribution is constant. The correct formula adds \(\mu^2\operatorname{Var}(N)=2^2(1/4)=1\).

A second check is whether conditional independence is justified. If the terms are dependent given the count, the conditional variance generally includes their conditional covariances:

$$ \operatorname{Var}(S_N\mid N=n) =\sum_{i=1}^{n}v_{i,n} +2\sum_{1\leq i<j\leq n} \operatorname{Cov}(X_i,X_j\mid N=n). $$

Thus the sum-of-variances step is not valid merely because the terms have the same marginal distribution. Check both how the count relates to the terms and whether the terms are conditionally independent.

Key takeaway: First condition on the count and calculate the total’s conditional mean and variance. Then average the conditional variance and add the variance of the conditional mean. Under independent, identically distributed summands, this yields \(\operatorname{Var}(S_N)=\sigma^2E[N]+\mu^2\operatorname{Var}(N)\).

Check Your Understanding

Use conditioning on the count in each question, and state any assumptions needed.

  1. If \(N\) is independent of iid summands with mean \(\mu\) and variance \(\sigma^2\), what are \(E[S_N]\) and \(\operatorname{Var}(S_N)\)? Identify the two parts of the variance.
  2. Suppose \(N\sim\operatorname{Poisson}(3)\) and independent summands have mean \(2\) and variance \(5\). Calculate the mean and variance of the random sum.
  3. Why does conditional independence allow the conditional variances of the summands to be added?
  4. If the summands’ conditional mean is \(m_N\) and their conditional variance is \(v_N\), what formulas apply when they are conditionally iid given \(N\)?
  5. What additional terms may appear in \(\operatorname{Var}(S_N\mid N=n)\) if the summands are not conditionally independent?