Comment 3 for bug 404001

Revision history for this message
zacek (miroslav-zacek) wrote : Re: wrong result of var() function

Maple gives also 4. I've computed the variance from definition and it is really 4 :-)

x_avg = average( x ) = 6

var(X) = average( x - x_avg)^2 ) = ( 1 + 1 + 1 + 1 + 4*4 ) / 5 = 20 / 5 = 4

var(X) = average( x^2 ) - average(x) ^ 2 = ( 5^2 + 5^2 + 5^2 + 5^2 + 10^2 ) / 5 - 6^2 = 200/5 - 36 = 4

The problem is that you calculate the biased corrected sample variance instead of sample variance. See the form (5) and read the article that follows this equation in http://mathworld.wolfram.com/Variance.html. WolframAlpha implements the biased corrected version a variance, Maple the not corrected version. I've tested it in Excel and it gives also the corrected version (i.e. 5). You should probably at least give some note to the help of the function list to avoid such confusion.