Tutorials › VEE Mathematical Statistics › Variance of a Weighted Sum of Many Variables

VEE Mathematical Statistics · Covariance and Correlation · Tutorial 312 of 880

Variance of a Weighted Sum of Many Variables

Learn to expand a weighted sum’s variance into individual variance terms and pairwise covariance terms, then calculate and check the result.

Intermediate 10 min read

What You'll Learn

  • State the conditions needed for the weighted-sum variance formula.
  • Derive the formula by expanding the centered weighted sum.
  • Count and organize the pairwise covariance terms for three or more variables.
  • Calculate a weighted portfolio’s variance from its variances and covariances.
  • Avoid sign and factor-of-two errors when applying the formula.

Why a Weighted Sum Needs Pairwise Covariances

When a total is formed from several random quantities, its uncertainty depends not only on how variable each quantity is, but also on how they vary together. For example, a portfolio total might combine several hypothetical loss amounts, with different weights applied to each. Adding the individual variances alone generally does not give the total variance: the relationships between distinct amounts also matter.

The two-variable case is a useful starting point, but a sum of \(n\) variables requires accounting for every distinct pair. The main task is to include each pair exactly once and apply the correct coefficient and factor of two.

Definition: Let \(X_1,\ldots,X_n\) be random variables with finite means and variances, and let \(w_1,\ldots,w_n\) be fixed, nonrandom numbers. Their weighted sum is $$ T=\sum_{i=1}^{n} w_iX_i. $$ The weights may be positive, negative, or zero. The variance formula below does not require the variables to be independent or to have a particular distribution.

For each distinct pair \(X_i,X_j\), the covariance is \(\operatorname{Cov}(X_i,X_j)=E[(X_i-E[X_i])(X_j-E[X_j])]\). A negative covariance contributes a negative term when the product of the weights is positive; the signs of both weights and the covariance must be considered together.

The General Formula

Theorem: If \(X_1,\ldots,X_n\) have finite variances and \(w_1,\ldots,w_n\) are fixed constants, then $$ \operatorname{Var}(T) = \sum_{i=1}^{n} w_i^2\operatorname{Var}(X_i) + 2\sum_{1\leq i<j\leq n}w_iw_j\operatorname{Cov}(X_i,X_j), \qquad T=\sum_{i=1}^{n}w_iX_i. $$ The second sum includes each unordered pair once. The factor \(2\) accounts for the two matching cross-products in the expansion of the square.

The first sum contains \(n\) individual variance terms. The second sum contains \(n(n-1)/2\) distinct pairs. For three variables, the three pairs are \((1,2)\), \((1,3)\), and \((2,3)\); for four variables, there are six pairs. A zero weight removes every term involving that variable, while a negative weight changes the signs of its terms according to the formula.

Why the Formula Holds

The derivation uses the definition of variance and the distributive law. Since the weights are fixed, centering the weighted sum centers each variable separately:

$$ T-E[T] = \sum_{i=1}^{n}w_i(X_i-E[X_i]). $$

Square this expression. Each squared term contributes a variance, and each product of two different centered variables contributes a covariance. Because \(X_i-E[X_i]\) and \(X_j-E[X_j]\) are ordinary scalar random variables, the cross-product for the pair \((i,j)\) occurs in both orders and the two products are equal.

$$ \begin{aligned} \operatorname{Var}(T) &=E\left[\left(\sum_{i=1}^{n}w_i(X_i-E[X_i])\right)^2\right]\\ &=\sum_{i=1}^{n}w_i^2E[(X_i-E[X_i])^2] +2\sum_{1\leq i<j\leq n}w_iw_j E[(X_i-E[X_i])(X_j-E[X_j])]\\ &=\sum_{i=1}^{n}w_i^2\operatorname{Var}(X_i) +2\sum_{1\leq i<j\leq n}w_iw_j\operatorname{Cov}(X_i,X_j). \end{aligned} $$

This proof also shows the limits of the result. The weights must be fixed constants for this expansion to have the stated form; random weights need separate treatment. Finite second moments are needed for the variances and covariances in the formula to be finite. No distributional assumption, such as normality, is needed.

Worked Example: Three Variables with Mixed Signs

Suppose \(X_1,X_2,X_3\) have means \(4,3,1\), variances \(5,2,3\), and covariances \(\operatorname{Cov}(X_1,X_2)=1\), \(\operatorname{Cov}(X_1,X_3)=-0.5\), and \(\operatorname{Cov}(X_2,X_3)=0.25\). Let \(T=X_1-X_2+2X_3\). Find \(E[T]\) and \(\operatorname{Var}(T)\). Assume a joint distribution with these finite moments; no particular distribution is specified. There is no interest, discounting, or mortality assumption in this statistical model.

Method. Use linearity of expectation for the mean, then apply the weighted-sum variance formula with weights \(w_1=1\), \(w_2=-1\), and \(w_3=2\).

First calculate the mean:

$$ E[T]=1(4)+(-1)(3)+2(1)=4-3+2=3. $$

The individual variance terms are:

$$ 1^2(5)+(-1)^2(2)+2^2(3)=5+2+12=19. $$

Next calculate the three pair contributions inside the covariance sum:

$$ \begin{aligned} w_1w_2\operatorname{Cov}(X_1,X_2)&=(1)(-1)(1)=-1,\\ w_1w_3\operatorname{Cov}(X_1,X_3)&=(1)(2)(-0.5)=-1,\\ w_2w_3\operatorname{Cov}(X_2,X_3)&=(-1)(2)(0.25)=-0.5. \end{aligned} $$

These terms sum to \(-2.5\), so their total contribution after multiplying by \(2\) is \(-5\). Therefore,

$$ \operatorname{Var}(T)=19+2(-2.5)=19-5=14. $$

Check. The negative covariance contribution reduces the individual-term total from \(19\) to \(14\), which is nonnegative as a variance must be. A common mistake here is to treat the negative weight on \(X_2\) as if it changed only the variance term. It also changes the sign of each pair term involving \(X_2\), as the products \(w_iw_j\) show.

Organizing Many Pair Terms

For a larger sum, a reliable approach is to make a list of all distinct pairs before substituting numbers. With four variables, there are six pairs; do not include both \((i,j)\) and \((j,i)\) in the pair list, because the formula already has a factor of \(2\). If a covariance is not supplied, do not silently set it to zero: use zero only when it is given or established from the model.

Worked Example: Four Variables and Six Possible Pairs

Let \(X_1,X_2,X_3,X_4\) have finite second moments and unspecified joint distribution. Suppose their variances are \(2,5,3,4\). The nonzero covariances are \(\operatorname{Cov}(X_1,X_2)=0.5\), \(\operatorname{Cov}(X_1,X_4)=-1\), \(\operatorname{Cov}(X_2,X_3)=0.25\), and \(\operatorname{Cov}(X_3,X_4)=1\); the other two pair covariances are zero. For \(T=X_1+2X_2-X_3+0.5X_4\), find the variance. No interest or mortality assumptions apply; this is a model specified by its moments, not by a named distribution.

Method. Use weights \(1,2,-1,0.5\). First sum the four individual terms:

$$ 1^2(2)+2^2(5)+(-1)^2(3)+(0.5)^2(4) =2+20+3+1=26. $$

Now list all six pairs so none are missed:

$$ \begin{aligned} (1,2):&(1)(2)(0.5)=1, & (1,3):&(1)(-1)(0)=0,\\ (1,4):&(1)(0.5)(-1)=-0.5, & (2,3):&(2)(-1)(0.25)=-0.5,\\ (2,4):&(2)(0.5)(0)=0, & (3,4):&(-1)(0.5)(1)=-0.5. \end{aligned} $$

The pair products sum to \(1+0-0.5-0.5+0-0.5=-0.5\). The covariance contribution is twice that sum, or \(-1\). Thus,

$$ \operatorname{Var}(T)=26+2(-0.5)=25. $$

Check. The result is positive, and all six pairs have been accounted for. A common mistake is to add the pair products only once, obtaining \(26-0.5=25.5\). The formula requires \(2\) times their sum, so the correct variance is \(25\).

Application to a Hypothetical Portfolio

A portfolio total is one practical setting for a weighted sum. The weights can represent the number of units or the amount of exposure assigned to each component. If each \(X_i\) is measured in thousands of dollars, the variance of the total is measured in squared thousands of dollars. The square root of that variance, if needed, returns to the original monetary units.

The example below is hypothetical. It specifies the relevant moments directly; the distribution of each loss is not specified. There is no discounting, interest rate, or mortality assumption in the calculation.

Worked Example: Variance of a Weighted Loss Portfolio

A hypothetical portfolio total, in thousands of dollars, is \(L=X_1+0.5X_2+2X_3\). The component means are \(12,8,5\), the variances are \(4,9,1\), and the covariances are \(\operatorname{Cov}(X_1,X_2)=2\), \(\operatorname{Cov}(X_1,X_3)=0.5\), and \(\operatorname{Cov}(X_2,X_3)=1.5\). Assume these moments come from a joint distribution with finite second moments. Find the expected portfolio total and its variance.

Method. First apply linearity of expectation using weights \(1,0.5,2\):

$$ E[L]=1(12)+0.5(8)+2(5)=12+4+10=26 $$

Thus the expected total is \(26\) thousand dollars. The individual variance terms are:

$$ 1^2(4)+(0.5)^2(9)+2^2(1)=4+2.25+4=10.25. $$

The three pair products are:

$$ \begin{aligned} (1)(0.5)(2)&=1,\\ (1)(2)(0.5)&=1,\\ (0.5)(2)(1.5)&=1.5. \end{aligned} $$

Their sum is \(3.5\), and the full covariance contribution is \(2(3.5)=7\). Therefore,

$$ \operatorname{Var}(L)=10.25+7=17.25 $$

in squared thousands of dollars. As a check in the original scale, the standard deviation is \(\sqrt{17.25}\approx4.153\) thousand dollars, rounded to three decimals; squaring \(4.153\) gives approximately \(17.247\), consistent with \(17.25\) after rounding. The expected total is \(26\) thousand dollars, or \(\$26{,}000\).

Common mistake avoided. The weights apply to the random amounts before variance is taken: each individual variance is multiplied by the squared weight, while each covariance is multiplied by the product of the two weights and then included with the factor \(2\).

Common Errors and a Practical Checklist

The most consequential errors are usually bookkeeping errors rather than difficult algebra. A negative weight affects both the squared individual term and the pair terms, although squaring makes its individual variance contribution nonnegative. A negative covariance does not automatically reduce the total variance: its effect depends on the product \(w_iw_j\). For example, a negative covariance paired with one positive and one negative weight gives a positive pair contribution.

Before finalizing a calculation, check these points:

  • Each individual variance is multiplied by the square of its weight.
  • Every distinct pair appears once in the pair sum, with its covariance and both weights.
  • The entire pair sum is multiplied by \(2\).
  • The covariance signs and weight signs are both retained.
  • The final result is nonnegative and has squared units.

A negative intermediate covariance contribution is not an error. It means that, for the given weights, the pairwise relationships reduce the variance relative to the sum of individual terms. The final variance, however, cannot be negative for a valid joint model.

Key takeaway: For a weighted sum of \(n\) variables, add the \(n\) squared-weight variance terms and twice the sum over all \(n(n-1)/2\) distinct covariance pairs. Keep the weights and signs attached to every term.

Check Your Understanding

For each problem, use the stated moments and fixed weights. Distributional assumptions are not required unless stated; no interest or mortality assumptions apply.

  1. Let \(T=2X_1-X_2+X_3\), where the variances are \(3,2,5\), \(\operatorname{Cov}(X_1,X_2)=-0.5\), \(\operatorname{Cov}(X_1,X_3)=0.25\), and \(\operatorname{Cov}(X_2,X_3)=1\). Find \(\operatorname{Var}(T)\). (Answer: 20)
  2. Let \(T=X_1-2X_2+0.5X_3+X_4\). The variances are \(2,1,4,3\); the nonzero covariances are \(\operatorname{Cov}(X_1,X_2)=0.25\), \(\operatorname{Cov}(X_1,X_4)=-0.5\), \(\operatorname{Cov}(X_2,X_3)=0.5\), and \(\operatorname{Cov}(X_3,X_4)=1\). All other pair covariances are zero. Find \(\operatorname{Var}(T)\). (Answer: 8)
  3. Let \(L=X_1+0.5X_2-X_3\), with means \(6,4,2\), variances \(1,4,9\), and covariances \(\operatorname{Cov}(X_1,X_2)=1\), \(\operatorname{Cov}(X_1,X_3)=-0.5\), and \(\operatorname{Cov}(X_2,X_3)=0.5\). Find both \(E[L]\) and \(\operatorname{Var}(L)\). (Answer: \(E[L]=6\); \(\operatorname{Var}(L)=12.5\))
  4. For \(T=X_1+2X_2-X_3+0.5X_4\), the variances are \(2,3,1,4\). The only nonzero covariances are \(\operatorname{Cov}(X_1,X_2)=0.5\), \(\operatorname{Cov}(X_1,X_4)=-1\), \(\operatorname{Cov}(X_2,X_3)=0.25\), and \(\operatorname{Cov}(X_3,X_4)=1\). Find \(\operatorname{Var}(T)\). (Answer: 15)
  5. Let \(T=X_1-X_2+2X_3+0.5X_4-2X_5\). The variances are \(1,2,1,4,1\). The only nonzero covariances are \(\operatorname{Cov}(X_1,X_2)=0.5\), \(\operatorname{Cov}(X_1,X_5)=-0.25\), \(\operatorname{Cov}(X_3,X_4)=0.5\), and \(\operatorname{Cov}(X_4,X_5)=0.5\). Find \(\operatorname{Var}(T)\). (Answer: 12)
Clinical Biostats