# Formula for the Variance of a sum of random variables

How do I show that $$\text{Var}\bigg(\sum_{i=1}^m X_i\bigg) = \sum_{i=1}^m \text{Var}(X_i) + 2\sum_{i\lt j} \text{Cov}(X_i,X_j)$$

when I know that $$\left(\sum_{i=1}^{n}a_i\right)^2= \sum_{i=1}^{n}\sum_{j=1}^{n}a_ia_j$$ and so $${\rm var} \left( \sum_{i=1}^{n} X_i \right) = \sum_{i=1}^{n} \sum_{j=1}^{n} \big( E(X_i X_j)-E(X_i) E(X_j) \big) = \sum_{i=1}^{n} \sum_{j=1}^{n} {\rm cov}(X_i, X_j)$$ where do I go from here to get the result?

• Separate the last sum depending on whether $i<j$, $i>j$ or $i=j$. It will give the terms you are seeking. Jul 27, 2019 at 19:16
• $cov(X_i,X_i)=var(X_i)$. For $i\ne j$, there are two equal terms for each $(i,j)$ combination. Jul 27, 2019 at 20:03

Please think about the RHS term $$\displaystyle \sum_{i=1}^{n} \sum_{j=1}^{n} Cov(X_i, X_j)$$

What happens when $$i = j$$?

$$Cov(X_i, X_j)$$ becomes $$Var(X_i)$$

When $$i \neq j$$, there are two terms viz., $$Cov(X_i, X_j)$$ and $$Cov(X_j, X_i)$$ in the summation. They are equal. Hence it is enough to replace the sum of these two terms by $$2 Cov(X_i, X_j)$$ when $$i < j$$. That is why you have a factor of $$2$$ before the single summation.

Hence

$$\displaystyle \sum_{i=1}^{n} \sum_{j=1}^{n} Cov(X_i, X_j)$$

$$= \displaystyle \sum_{i=1}^{n} Var (X_i) + 2 \displaystyle \sum_{i < j} Cov(X_i, X_j)$$

You can simplify the proof by introducing the variable $$Y_i=X_i-EX_i$$. Using the fact that variance of $$X$$ is same as variance of $$X+c$$ for any constant $$c$$ the given statement is equivalent to: $$var ( \sum\limits_{i=1}^{n} Y_i) =\sum\limits_{i=1}^{n} var(Y_i) + \sum\limits_{i \neq j} EY_iY_j$$ or $$E ( \sum\limits_{i=1}^{n} Y_i)^{2} =\sum\limits_{i=1}^{n} EY_i^{2} + \sum\limits_{i\neq j} EY_iY_j$$. This follows from the fact that $$( \sum\limits_{i=1}^{n} Y_i)^{2} =\sum\limits_{i=1}^{n} Y_i^{2} + \sum\limits_{i\neq j} Y_iY_j$$.

Note that $$2 \sum\limits_{i < j} cov(X_i,X_j) = \sum\limits_{i \neq j} cov(X_i,X_j)$$