I have dataset with 61 entries. What i am trying to do is to calculate variance.
I am doing it with two ways but they differ
1st way is following
$var X = E(X^{2}) - (EX)^{2}$
so
> c = 0
> for( year in females$Salary )
+ c = c + (year^2)
> (c/length(females$Salary) - mean(females$Salary)^2
[1] 286682.3
but when i use build in function
> var(females$Salary)
[1] 291460.3
as u can see the output is different. Why is this happening? Shouldnt they be the same?