Covariance and variance

Within the context of simple linear regression, I came across this:

$$\hat{\beta}=\frac{\sum y_nx_n}{\sum x_n^2}=\frac{cov(xy)}{var(x)}$$

where I assume $cov(x,y)$ means the covariance between $x$ and $y$, and $var(x)$ means the variance of $x$. I wonder how is this equivalence derived?

-
That assumes that $x$ and $y$ have zero mean. Further, the summations are random variables, they are not really equal to the terms on the right, but approximate them (as estimators -under suitable conditions). Eg: $\sum x^2_n /n \to var(x)$ –  leonbloy Apr 30 '12 at 20:15
@leonbloy, that (the zero mean assumption) is what I speculated, but it seems to make no sense for the context of the material I'm looking at, i.e. page 10 of elsa.berkeley.edu/eml/ra_reader/1-regression.pdf –  Aaron Apr 30 '12 at 20:29
it's ok: see page 10. $x_n = X_n - \bar{X}$ (in lowercase) is zero mean. –  leonbloy Apr 30 '12 at 20:41
Only $x$ should have zero mean. –  Did Apr 30 '12 at 23:02