# Determining variance of sum of both correlated and uncorrelated random variables

David Mitra had a great, simple answer to a similar question of how to determine the variance of the sum of two correlated random variables. What if, however, I have three normally distributed random variables, only two of which are correlated with one another - how do I find the variance? My thinking is that since

Var(A+B) = Var(A)+ Var(B)+ 2Cov(A,B)

works for two correlated variables, maybe you can just throw in a third, uncorrelated variable C getting:

Var(A+B+C) = Var(A) + Var(B) + Var(C) + 2Cov(A,B)

Also, what if I have more variables and more of those variables are correlated? Say I have variables A, B, C, D and E and A, B and C are all correlated to one another. Would this be a possible solution:

Var(A+B+C+D+E) = Var(A) + Var(B) + Var(C) + Var(D) + Var(E) + 2Cov(A,B) + 2Cov(A,C) + 2Cov(B,C)

• You first and third equation are right. The second equation is right if A,C and B,C are uncorrelated. Jul 30, 2018 at 22:42
• @callculus I did mean to C is uncorrelated to the other two variables in the second equation - I'll edit that now. Thank you Jul 30, 2018 at 22:45

Since $\mathsf {Var}(S)=\mathsf{Cov}(S,S)$ and $\mathsf{Cov}(S,T)=\mathsf{Cov}(T,S)$, and covariance is bilinear, we have that:\begin{align}\mathsf {Var}(A+B) & =\mathsf{Cov}(A+B,A+B)\\ &=\mathsf{Cov}(A,A)+\mathsf{Cov}(A,B)+\mathsf{Cov}(B,A)+\mathsf{Cov}(B,B) \\ &= \mathsf{Var}(A)+2\mathsf{Cov}(A,B)+\mathsf{Var}(B)\end{align}

Likewise, in general:

\begin{align}\mathsf{Var}(\sum_{i}A_i) &=\mathsf {Cov}(\sum_i A_i,\sum_j A_j)\\ &= \sum_i\sum_j\mathsf{Cov}(A_i,A_j)\\&=\sum_i\mathsf{Var}(A_i)+2\sum_{i<j}\mathsf{Cov}(A_i,A_j)\end{align}

And specifically:\begin{align}\mathsf{Var}(A+B+C) &=\mathsf {Cov}(A+B+C,A+B+C)\\&~~\vdots\\&=\mathsf{Var}(A)+\mathsf{Var}(B)+\mathsf{Var}(C)+2\mathsf{Cov}(A,B)+2\mathsf{Cov}(A,C)+2\mathsf{Cov}(B,C)\end{align}

And so on.   Of course, if any two variables are pairwise uncorrelated, their relevant covariance term will vanish.

By using the formalism of the matrix of covariance you can easily extend to every possible case. Remember that uncorrelated variables have zero covariance so you would just have some zeros in the matrix.

I've answered a similar question on this post that maybe can shed some light on the problem!

If you have a sum of $N$ variables such as $$W = \sum_{n=1}^Na_nX_n$$ you can write the variance of $W$ in matrix formalism as $$\operatorname{Var}[W] = \mathbf{v}^T\mathbf{M}\mathbf{v}$$ where $\mathbf{v}$ is a vector containing all the $a_n$, mainly $$\mathbf{v} = \left(\begin{matrix}a_1\\a_2\\\vdots\\a_n\end{matrix}\right)$$ and the matrix $\mathbf{M}$ is the matrix of covariance defined as $$\left(\begin{matrix}\operatorname{Var}[X_1]&\operatorname{Cov}[X_1,X_2]&\operatorname{Cov}[X_1,X_3]&\cdots&\operatorname{Cov}[X_1,X_n]\\\operatorname{Cov}[X_2,X_1]&\operatorname{Var}[X_2]&\operatorname{Cov}[X_2,X_3]&\cdots&\operatorname{Cov}[X_2,X_n]\\\vdots&\vdots&\vdots&\ddots&\vdots\\\operatorname{Cov}[X_n,X_1]&\operatorname{Cov}[X_n,X_2]&\operatorname{Cov}[X_n,X_3]&\cdots&\operatorname{Var}[X_n]\end{matrix}\right)$$ which is a symmetric matrix, because $\operatorname{Cov}[X,Y]=\operatorname{Cov}[Y,X]$ and positive semidefinite