Tutorials › Exam P - Probability › The Two-Variable Variance-of-a-Sum Formula

Exam P · Covariance and Correlation · Tutorial 757 of 915

The Two-Variable Variance-of-a-Sum Formula

Learn to calculate the variance of a sum when two random variables may be dependent, and check the result using the distribution of their total.

Intermediate 10 min read

What You'll Learn

  • Derive the two-variable variance-of-a-sum formula from the definition of variance.
  • Identify the finite-second-moment condition needed for the formula.
  • Calculate covariance and variance of a sum from a joint distribution.
  • Apply the formula to dependent indicator payments.
  • Check a variance calculation by finding the distribution of the sum directly.
  • Avoid omitting the covariance term or using it without its factor of two.

Why Covariance Matters When Adding Random Variables

When a total is formed by adding two random quantities, its variance is not determined by their individual variances alone. The quantities may tend to be high together, or one may tend to be high when the other is low. Covariance measures this aspect of their joint behavior and is therefore part of the variance calculation. This matters in actuarial applications such as combining payments, expenses, or other uncertain amounts.

The formula in this tutorial applies whether the variables are independent or dependent. In particular, when dependence is present, leaving out covariance can substantially misstate the variability of the total. The focus here is the two-variable sum \(X+Y\); no assumption of independence is required.

Definition: For random variables \(X\) and \(Y\) with finite second moments, their covariance is $$ \operatorname{Cov}(X,Y)=E[(X-E[X])(Y-E[Y])]. $$ Their variances are \(\operatorname{Var}(X)=E[(X-E[X])^2]\) and \(\operatorname{Var}(Y)=E[(Y-E[Y])^2]\). Finite second moments mean \(E[X^2]<\infty\) and \(E[Y^2]<\infty\), which ensure that the variances and covariance in the formula below are finite.

The Variance-of-a-Sum Formula

Theorem: If \(X\) and \(Y\) have finite second moments, then $$ \operatorname{Var}(X+Y) = \operatorname{Var}(X)+\operatorname{Var}(Y)+2\operatorname{Cov}(X,Y). $$ The variables need not be independent. The covariance term accounts for their dependence.

The coefficient \(2\) arises because the square of a sum contains two identical cross-products. Center each variable by subtracting its own mean, and expand the square:

$$ \begin{aligned} \operatorname{Var}(X+Y) &=E\left[\left((X+Y)-E[X+Y]\right)^2\right]\\ &=E\left[\left((X-E[X])+(Y-E[Y])\right)^2\right]\\ &=E[(X-E[X])^2] +2E[(X-E[X])(Y-E[Y])] +E[(Y-E[Y])^2]\\ &=\operatorname{Var}(X)+2\operatorname{Cov}(X,Y)+\operatorname{Var}(Y). \end{aligned} $$

The second line uses linearity of expectation, \(E[X+Y]=E[X]+E[Y]\). The third line is the algebraic identity \((a+b)^2=a^2+2ab+b^2\), applied to the centered variables. Taking expectations gives the variances for the squared terms and the covariance for the cross-product. This derives the formula without requiring any assumption about the joint distribution beyond the finite-second-moment condition.

Key takeaway: To find the variance of a sum, add the two individual variances and twice the covariance. A positive covariance increases the variance of the sum; a negative covariance decreases it. The covariance must be in the same units as the product of the two variables.

Using a Joint Distribution

A reliable method for a discrete pair is to obtain each mean, variance, and the cross-product expectation from the joint distribution. In particular, the product-moment identity \(\operatorname{Cov}(X,Y)=E[XY]-E[X]E[Y]\) can make the covariance calculation straightforward. After applying the theorem, calculate the distribution of \(X+Y\) directly when the joint outcomes are manageable. Agreement between the two methods is an effective check.

Worked Example: Two Hypothetical Payments With Dependence

A hypothetical contract has two payment components \(X=5I_A\) and \(Y=8I_B\), where \(I_A\) is 1 if event \(A\) occurs and 0 otherwise, and \(I_B\) is 1 if event \(B\) occurs and 0 otherwise. Suppose the only possible indicator pairs and their probabilities are \((1,0)\) with probability 0.20, \((0,1)\) with probability 0.30, and \((0,0)\) with probability 0.50. Find \(\operatorname{Var}(X+Y)\). All amounts are hypothetical and are in dollars.

Method. Calculate the component variances and covariance from the joint outcomes, then use the variance-of-a-sum formula. Since the two events cannot occur together in this model, their indicator variables are dependent.

First, \(P(I_A=1)=0.20\) and \(P(I_B=1)=0.30\). Thus \(E[X]=5(0.20)=1\) and \(E[Y]=8(0.30)=2.4\). For an indicator with success probability \(p\), its variance is \(p(1-p)\), so \(\operatorname{Var}(X)=25(0.20)(0.80)=4\) and \(\operatorname{Var}(Y)=64(0.30)(0.70)=13.44\).

The events are mutually exclusive, so \(E[I_AI_B]=0\), and therefore \(E[XY]=40E[I_AI_B]=0\). The covariance is \(\operatorname{Cov}(X,Y)=E[XY]-E[X]E[Y]=0-(1)(2.4)=-2.4\). Now apply the formula:

$$ \operatorname{Var}(X+Y)=4+13.44+2(-2.4)=12.64. $$

Direct check. The total \(X+Y\) is 5 with probability 0.20, 8 with probability 0.30, and 0 with probability 0.50. Its mean is \(0.20(5)+0.30(8)+0.50(0)=3.4\). Its second moment is \(0.20(25)+0.30(64)+0.50(0)=24.2\). Hence its variance is \(24.2-(3.4)^2=24.2-11.56=12.64\), matching the formula. The answer is \(12.6400\) dollars squared.

Common mistake avoided. Adding the component variances alone gives \(4+13.44=17.44\), which is wrong because it omits the covariance contribution. Here the negative covariance reduces the variance by \(4.8\).

Calculating From a Joint Probability Table

A joint table records probabilities for pairs of values, not just separate probabilities for \(X\) and \(Y\). To calculate covariance from such a table, multiply each outcome pair to obtain \(XY\), weight by its joint probability, and sum to find \(E[XY]\). Then subtract \(E[X]E[Y]\). The following example shows how the joint pairing affects the result even when the individual distributions are also needed.

Worked Example: A Joint Table for Two Hypothetical Costs

A hypothetical project has two costs \(X\) and \(Y\), measured in thousands of dollars. Their joint distribution is:

\(X\)\(Y\)Probability
120.20
160.30
520.10
560.40

Find the variance of the total cost \(X+Y\), in squared thousands of dollars. First check the probabilities: \(0.20+0.30+0.10+0.40=1.00\).

The marginal probabilities for \(X=1\) and \(X=5\) are \(0.20+0.30=0.50\) and \(0.10+0.40=0.50\). Therefore \(E[X]=1(0.50)+5(0.50)=3\), and \(E[X^2]=1^2(0.50)+5^2(0.50)=13\). Thus \(\operatorname{Var}(X)=13-3^2=4\).

For \(Y\), the marginal probabilities are \(P(Y=2)=0.20+0.10=0.30\) and \(P(Y=6)=0.30+0.40=0.70\). Hence \(E[Y]=2(0.30)+6(0.70)=4.8\), and \(E[Y^2]=2^2(0.30)+6^2(0.70)=1.2+25.2=26.4\). It follows that \(\operatorname{Var}(Y)=26.4-(4.8)^2=26.4-23.04=3.36\).

Next calculate the joint product expectation: \(E[XY]=2(0.20)+6(0.30)+10(0.10)+30(0.40)=0.4+1.8+1+12=15.2\). Therefore \(\operatorname{Cov}(X,Y)=15.2-(3)(4.8)=15.2-14.4=0.8\). The variance of the sum is \(\operatorname{Var}(X+Y)=4+3.36+2(0.8)=8.96\).

Direct check. The possible totals are 3, 7, 7, and 11, with probabilities 0.20, 0.30, 0.10, and 0.40. Their mean is \(3(0.20)+7(0.30)+7(0.10)+11(0.40)=0.6+2.1+0.7+4.4=7.8\). The second moment is \(9(0.20)+49(0.30)+49(0.10)+121(0.40)=1.8+14.7+4.9+48.4=69.8\). Thus the variance is \(69.8-(7.8)^2=69.8-60.84=8.96\). The answer is \(8.96\) squared thousands of dollars.

The check also illustrates why the joint pairing matters: it is the probabilities attached to pairs of values that determine \(E[XY]\), and thus covariance.

How the Sign of Covariance Affects a Total

For fixed component variances, the covariance term determines whether combining the variables increases or decreases the variance relative to the sum of those component variances. A positive covariance contributes a positive amount; a negative covariance contributes a negative amount. This does not mean a variance can become negative: the total is itself a variance and cannot be less than zero. Rather, the component variances and covariance together describe the variation of the combined quantity.

Do not infer covariance from the separate means or variances alone. Those summaries describe each variable individually; covariance depends on how their values occur together. Use a stated joint distribution or other information that determines their joint behavior. If the information given does not determine covariance, it is not enough to calculate \(\operatorname{Var}(X+Y)\) numerically.

Worked Example: A Negative Covariance in a Total

Suppose hypothetical component amounts \(X\) and \(Y\), each measured in dollars, have \(\operatorname{Var}(X)=9\), \(\operatorname{Var}(Y)=4\), and \(\operatorname{Cov}(X,Y)=-2\). Find the variance of their sum and explain the role of the covariance.

Method. Substitute the three supplied quantities directly into the theorem: \(\operatorname{Var}(X+Y)=9+4+2(-2)=13-4=9\) dollars squared.

The component variances add to 13 dollars squared before accounting for their joint behavior. The negative covariance contributes \(-4\), leaving variance 9. A common error is to write \(9+4-2=11\), using the covariance only once. The cross-product in the centered square appears twice, so the correct contribution is \(2(-2)=-4\).

Check. The result is nonnegative, as a variance must be. The negative covariance makes the total less variable than it would be if the covariance term were zero, while the stated information is sufficient to determine the total variance.

Common Exam Traps

  • Omitting covariance. The expression \(\operatorname{Var}(X)+\operatorname{Var}(Y)\) is not the general formula for \(\operatorname{Var}(X+Y)\). It leaves out the dependence information.
  • Forgetting the factor of two. The term is \(2\operatorname{Cov}(X,Y)\), not just \(\operatorname{Cov}(X,Y)\). It comes from the two equal cross-products when the centered sum is squared.
  • Using the wrong sign. A negative covariance is added as a negative quantity: for example, \(+2(-2)=-4\). Do not subtract a negative covariance a second time.
  • Confusing covariance with a component variance. Covariance can be positive, negative, or zero. A variance cannot be negative.
  • Failing to check the joint outcomes. If a joint distribution is provided, verify its probabilities sum to 1 and use the probability of each pair when finding \(E[XY]\).
  • Reporting the wrong units. If \(X\) and \(Y\) are dollars, their variances and covariance are in dollars squared. If amounts are in thousands of dollars, the resulting variance is in squared thousands of dollars.
Key takeaway: For variables with finite second moments, calculate \(\operatorname{Var}(X+Y)\) as \(\operatorname{Var}(X)+\operatorname{Var}(Y)+2\operatorname{Cov}(X,Y)\). When possible, verify the answer from the distribution of the sum.

Check Your Understanding

For each problem, identify the component variances and covariance when needed. Use the variance-of-a-sum formula, and check that the sign and factor of two are handled correctly.

  1. A joint distribution assigns probability 0.50 to \((X,Y)=(0,0)\), probability 0.25 to \((2,1)\), and probability 0.25 to \((4,3)\). Find \(\operatorname{Var}(X+Y)\). (Answer: \(8.2500\))
  2. Suppose \(\operatorname{Var}(X)=9\), \(\operatorname{Var}(Y)=4\), and \(\operatorname{Cov}(X,Y)=-2\). Find \(\operatorname{Var}(X+Y)\). (Answer: \(9.0000\))
  3. Hypothetical payments are \(X=6I_A\) and \(Y=10I_B\). The mutually exclusive events \(A\) and \(B\) have probabilities 0.20 and 0.30, and neither occurs with probability 0.50. Find \(\operatorname{Var}(X+Y)\). (Answer: \(19.5600\) dollars squared)
  4. A joint distribution for two hypothetical costs, in thousands of dollars, assigns probabilities 0.10, 0.40, 0.30, and 0.20 to \((X,Y)=(1,0),(1,4),(5,0),(5,4)\), respectively. Find \(\operatorname{Var}(X+Y)\). (Answer: \(4.6400\) squared thousands of dollars)
Clinical Biostats