# Covariance of sums of random variables to variances?

I have the following example:

Let $$Y_1, \dots, Y_n$$ be an i.i.d. $$N(\mu, \sigma^2)$$. Note that $$\sum_{i = 1}^n (y_i - \mu)^2 = \sum_{i = 1}^n (y_i - \bar{y})^2 + n(\bar{y} - \mu)^2$$.

We show that $$Y$$ and $$\sum_{i = 1}^n (Y_i - \bar{Y})^2$$ are independent.

One can show that

\begin{align} \text{Cov}(\bar{Y}, Y_i - \bar{Y}) &= \dfrac{1}{n^2} \text{Cov} \left( \sum_{j = 1}^n Y_j, nY_i - \sum_{j = 1}^n Y_j \right) \\ &= \dfrac{1}{n^2} \left( (n - 1)\text{Var}(Y_i) - \sum_{j = 1, j \not= i}^n \text{Var}(Y_j) \right) \\ &= \dfrac{1}{n^2} ((n - 1) \sigma^2 - (n - 1)\sigma^2) \\ &= 0 \end{align}

Since $$(\bar{Y}, Y_i - \bar{Y})$$ is normally distributed and this implies $$\bar{Y}$$ and $$Y_i - \bar{Y}$$ are independent for all $$i$$. So $$\bar{Y}$$ and $$(Y_1 - \bar{Y}, \dots, Y_n - \bar{Y})$$ are also independent. This implies $$\bar{Y}$$ and $$\sum_{i = 1}^n (Y_i - \bar{Y})^2$$ are independent.

How did the authors get from $$\dfrac{1}{n^2} \text{Cov} \left( \sum_{j = 1}^n Y_j, nY_i - \sum_{j = 1}^n Y_j \right)$$ to $$\dfrac{1}{n^2} \left( (n - 1)\text{Var}(Y_i) - \sum_{j = 1, j \not= i}^n \text{Var}(Y_j) \right)$$?

I would greatly appreciate it if people would please take the time to clarify this.

It comes from the distributive property of covariance: \begin{align}C&=\text{Cov} \left( \sum_{j = 1}^n Y_j, nY_i - \sum_{j = 1}^n Y_j \right)=\operatorname{cov}\left(\sum_{j=1}^n Y_j, nY_i\right)-\operatorname{cov}\left(\sum_{j=1}^n Y_j,\sum_{k=1}^n Y_k\right)\\&= n\sum_{j=1}^n\operatorname{cov}\left(Y_j,Y_i\right)-\sum_{j=1}^n\sum_{k=1}^n \operatorname{cov}(Y_j,Y_k)\\&=n\operatorname{cov}(Y_i,Y_i)-\sum_{j=1}^n\operatorname{cov}(Y_j,Y_j)=n\operatorname{var}(Y_i)-\sum_{j=1}^n\operatorname{var}(Y_j)\\&=n\operatorname{var}(Y_i)-\operatorname{var}(Y_i)-\sum_{j=1,j\neq i}^n\operatorname{var}(Y_j)\\&=(n-1)\operatorname{var}(Y_i)-\sum_{j=1,j\neq i}^n\operatorname{var}(Y_j)\end{align}
• Thanks again! There seems to be an interesting property of covariance here that I was not familiar with: $\sum_{j = 1}^n \text{cov}(Y_j, Y_i) = \text{cov}(Y_i, Y_i)$. – The Pointer Mar 14 at 21:08
• it doesn't directly come from properties of covariance. the covariance between $Y_i$ and $Y_j$ is $0$ if $i\neq j$ (because in the question it's said iid), so in the summation only $j=i$ remains. – gunes Mar 14 at 21:27