I always thought I understood the concept of variance, but this one confuses me.
$ \begin{eqnarray} X & := & (1, 2, 3)\\ E(X) & = & (1 + 2 + 3) / 3 = 2\\ Var(X) & = & Cov(X, X) = E((X - E(X))^2)\\ & = & E((-1, 0, 1)^2)\\ & = & E(1,0,1)\\ & = & 2/3 \end{eqnarray} $
But R
tells me that
> var(c(1,2,3))
[1] 1
Which part of my calculation is wrong?