# Calculating the Covariance matrix for the mean of variables

Assume that we have 3 3D points to make this questions simpler.

$$pt_1 = \begin{bmatrix} x_1 & y_1 & z_1 \end{bmatrix} \\ pt_2 = \begin{bmatrix} x_2 & y_2 & z_2 \end{bmatrix} \\ pt_3 = \begin{bmatrix} x_3 & y_3 & z_3 \end{bmatrix}$$

and we also have the variance-covariance matrix for each point

$$c_1 = \begin{bmatrix} s_{x_1} & s_{x_1y_1} & s_{x_1z_1} \\ s_{x_1y_1} & s_{y_1} & s_{y_1z_1} \\ s_{x_1z_1} & s_{y_1z_1} & s_{z_1} \end{bmatrix}, c_2 = \begin{bmatrix} s_{x_2} & s_{x_2y_2} & s_{x_2z_2} \\ s_{x_2y_2} & s_{y_2} & s_{y_2z_2} \\ s_{x_2z_2} & s_{y_2z_2} & s_{z_2} \end{bmatrix} c_3 = \begin{bmatrix} s_{x_3} & s_{x_3y_3} & s_{x_3z_3} \\ s_{x_3y_3} & s_{y_3} & s_{y_3z_3} \\ s_{x_3z_3} & s_{y_3z_3} & s_{z_3} \end{bmatrix}$$

I can easily calculate the average 3d point comprised of the 3 points above. How would I calculate the variance-covariance matrix of the calculated average point ?

• Hint: covariance is a linear operation. – amoeba May 23 '16 at 19:12
• I read that the variance parts are pretty much the quadrature over 3, in this case. So there is no difference for the correlations then I guess. – xerion May 23 '16 at 19:22
• Just to clarify my previous comment: assuming that all between-point covariances are zero, you have simply $c=(c_1+c_2+c_3)/9$. There is no need to go through any computations at all. – amoeba May 23 '16 at 20:26

Let $\overline{pt}=\frac{pt_1+pt_2+pt_3}{3}$. Then the covariance matrix of $\overline{pt}$ should be:

$C_\overline{pt} = \left[\matrix{Cov(\bar{x},\bar{x}) & Cov(\bar{x},\bar{y}) & Cov(\bar{x},\bar{z}) \\ Cov(\bar{x},\bar{y}) & Cov(\bar{y},\bar{y}) & Cov(\bar{y},\bar{z})\\ Cov(\bar{x},\bar{z}) & Cov(\bar{y},\bar{z}) & Cov(\bar{z},\bar{z})\\}\right]$

Note that $Cov(A,A)=Var(A)$ for any random variable $A$. This will simplify all of the elements on the diagonal.

In addition, consider $Cov(\bar{x},\bar{y})$.

$\begin{eqnarray*} Cov(\bar{x},\bar{y}) &=& Cov\left(\frac{x_1+x_2+x_3}{3},\frac{y_1+y_2+y_3}{3}\right) \\ &=& \frac{1}{3}\times\frac{1}{3}\times Cov\left(x_1+x_2+x_3,y_1+y_2+y_3\right) \\ &=& \frac{1}{9}\left[Cov(x_1,y_1)+Cov(x_2,y_1)+Cov(x_3,y_1)+Cov(x_1,y_2)+Cov(x_2,y_2)+Cov(x_3,y_2)+Cov(x_1,y_3)+Cov(x_2,y_3)+Cov(x_3,y_3)\right] \\ &=& \frac{1}{9}\left[s_{x_1y_1}+s_{x_2y_1}+s_{x_3y_1}+s_{x_1y_2}+s_{x_2y_2}+s_{x_3y_2}+s_{x_1y_3}+s_{x_2y_3}+s_{x_3y_3}\right] \\ &=& \frac{1}{9}\sum_{i=1}^3\sum_{j=1}^3s_{x_iy_j} \end{eqnarray*}$

This, of course, generalizes to $Cov(\bar{y},\bar{z})$ and $Cov(\bar{x},\bar{z})$.

Combining the above results, the covariance matrix $C_\overline{pt}$ simplifies to the following:

$C_\overline{pt}=\left[\matrix{s_\bar{x} & \frac{1}{9}\sum_{i=1}^3\sum_{j=1}^3s_{x_iy_j} & \frac{1}{9}\sum_{i=1}^3\sum_{j=1}^3s_{x_iz_j} \\ \frac{1}{9}\sum_{i=1}^3\sum_{j=1}^3s_{x_iy_j} & s_\bar{y} & \frac{1}{9}\sum_{i=1}^3\sum_{j=1}^3s_{y_iz_j}\\ \frac{1}{9}\sum_{i=1}^3\sum_{j=1}^3s_{x_iz_j} & \frac{1}{9}\sum_{i=1}^3\sum_{j=1}^3s_{y_iz_j} & s_\bar{z}\\}\right]$

• I guess this is the full blown out formula when there is also correlation between the 3 points themselves. In my case this $$\frac{1}{9}\left[s_{x_1y_1}+s_{x_2y_1}+s_{x_3y_1}+s_{x_1y_2}+s_{x_2y_2}+s_{x_3y_2}+s_{x_1y_3}+s_{x_2y_3}+s_{x_3y_3}\right]$$ will be simplified to $$\frac{1}{9}\left[s_{x_1y_1}+s_{x_2y_2}+s_{x_3y_3}\right]$$ – xerion May 23 '16 at 19:37
• If you can assume independence between $pt_1$, $pt_2$, and $pt_3$, then yes. – Matt Brems May 23 '16 at 19:38
• And just confirming that indeed the diagonal terms are $$\frac{\sqrt{(s_{x1}^2+s_{x2}^2+s_{x3}^2)}}{3}$$ – xerion May 23 '16 at 19:42
• Assuming $pt_1$, $pt_2$, and $pt_3$ are independent of one another, $Var(\overline{x})=Var(\frac{x_1+x_2+x_3}{3}=\frac{1}{9}\left[Var(x_1)+Var(x_2)+Var(x_3)\right]=\frac{1}{9}\left[s_{x_1}+s_{x_2}+s_{x_3}\right]$. If they are not independent of one another, then there will be additional covariance terms on the back end. ($2s_{x_1x_2}$,$2s_{x_1x_3}$,$2s_{x_2x_3}$) – Matt Brems May 23 '16 at 19:49