4

I've seen $\text{cov}(x,y)$ expressed as $$\dfrac{\sum_{i=1}^n (x_i - \bar{x})(y_i - \bar{y})}{n} \tag{1}$$ and also as $E[xy] - E[x]E[y]$. The latter expands to $$\frac{\sum_{i=1}^nx_iy_i}{n} - \left(\frac{\sum_{i=1}^nx_i}{n}\right)\left(\frac{\sum_{i=1}^ny_i}{n}\right) \tag{2}$$

Despite lots of effort trying to manipulate $(1)$ to become $(2)$ I've failed and would like some help. I started by expanding $(1)$ into $$\dfrac{\sum_{i=1}^nx_iy_i}{n} + \bar{x}\bar{y} - \dfrac{\sum_{i=1}^nx_i\bar{y}}{n} - \dfrac{\sum_{i=1}^ny_i\bar{x}}{n}$$

then eyeballing that with $(2)$ to get $$\bar{x}\bar{y} - \dfrac{\sum_{i=1}^nx_i\bar{y}}{n} - \dfrac{\sum_{i=1}^ny_i\bar{x}}{n} = -\left(\frac{\sum_{i=1}^nx_i}{n}\right)\left(\frac{\sum_{i=1}^ny_i}{n}\right) \tag{3}$$

I would like to be shown how to manipulate the LHS of $(3)$ to be the RHS.

PeteUK
  • 1,570
  • 3
    Remember what $\bar{x},\bar{y}$ represent. You will kick yourself at the simplicity afterwards ;). – Chinny84 Jun 19 '14 at 15:01
  • 1
    Hint: $\dfrac{\sum_{i=1}^n \bar{x}(y_i - \bar{y})}{n} = 0$. – PA6OTA Jun 19 '14 at 15:10
  • @PA6OTA thanks for the hint. I didn't understand how it was helpful yesterday but now see how it simplifies things. I suppose you see it clearer if you expand $(x_i - \bar{x})(y_i - \bar{y})$ into $x_i(y_i - \bar{y}) - \bar{x}(y_i - \bar{y})$ where I tend to expand directly into four terms. – PeteUK Jun 20 '14 at 11:14

1 Answers1

2

You have it already.

$$\dfrac{\sum_{i=1}^nx_iy_i}{n} + \bar{x}\bar{y} - \dfrac{\sum_{i=1}^nx_i\bar{y}}{n} - \dfrac{\sum_{i=1}^ny_i\bar{x}}{n}=\dfrac{\sum_{i=1}^nx_iy_i}{n} - \bar{x}\bar{y}$$

because

$$\dfrac{\sum_{i=1}^nx_i\bar{y}}{n}=\bar{y}\dfrac{\sum_{i=1}^nx_i}{n}=\bar{x}\bar{y}$$

and

$$\dfrac{\sum_{i=1}^ny_i\bar{x}}{n}=\bar{x}\dfrac{\sum_{i=1}^ny_i}{n}=\bar{x}\bar{y}$$

RRL
  • 90,707