Alternative formula for sample covariance Is this an equivalent formula for the sample covariance?
$$\frac{1}{n-1}\left(\sum_{i=1}^nx_iy_i -n\overline{x}\overline{y}\right)$$
Thanks
 A: It is an equivalent formula to $\frac{1}{n-1}\sum_{i=1}^{n} (x_i-\overline x)(y_i-\overline y)$
Firstly you can multiply out the brackets.
$\sum_{i=1}^{n} (x_i-\overline x)(y_i-\overline y)=\sum_{i=1}^{n}x_iy_i-\sum_{i=1}^{n}x_i\overline y-\sum_{i=1}^{n}\overline x y_i+ \overline x \ \overline y\sum_{i=1}^{n} 1$
$\overline x$ and $\overline y$ are both constants. Thus they can be put in front of the sigma signs.
$=\sum_{i=1}^{n}x_iy_i-\overline y\overline x-\overline x\sum_{i=1}^{n} y_i+\overline x \  \overline y\sum_{i=1}^{n} 1$


*

*$\overline x=\frac{1}{n}\sum_{i=1}^n x_i\Rightarrow n\cdot \overline
   x=\sum_{i=1}^n x_i$.

*Similar for $y_i$
$=\sum_{i=1}^{n}x_iy_i-n\cdot \overline y \ \overline x-n \cdot \overline x \ \overline y+\overline x \  \overline y\sum_{i=1}^{n} 1$


*

*$\sum_{i=1}^n 1=n$


$=\sum_{i=1}^{n}x_iy_i-n\cdot \overline y \ \overline x\underbrace{-n \cdot \overline x \ \overline y+n\cdot \overline x \  \overline y}_{=0}$
Finally we get
$\sum_{i=1}^{n} (x_i-\overline x)(y_i-\overline y)=\sum_{i=1}^{n}x_iy_i-n\cdot \overline y \ \overline x$
