Hello,
while calculating some variances, I found that the built-in function var() has a very surprising behaviour:
Code: Select all
objref T
T = new Vector(2)
T.x[1] = 1
T.var()
more surprising
Code: Select all
objref T
T = new Vector(4)
T.x[0] = 1
T.x[1] = 1
T.var()
This likely means that this function thinks the number of elements in T is { T.size()-1 }
##### EDIT #####
Vector.var() actually computes the best estimator of the variance for the vect. Meaning
if, for i in 1, N, X(i) are independent realisations of the law X
then sig² =[ X(1)² + .... + X(N)² - ( X(1) + .... + X(N) )² ] / N
is NOT a good estimator of Var(X) because E(sig²) = Var(X) * (N-1)/N
N/(N-1) * sig² is a better estimator
So, Vector.var() is not bugged, it's just surprising