You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by en...@gmx.com on 2011/10/22 17:34:14 UTC

[math] variance result

I'm utterly sorry to pose such a dumb question, but:

the variance of the values 2, 4, and 6: shouldn't that be 2.67 ? The StatUtils and DescriptveStatistics give me 4.

My calculation (that I checked a dozen times) is: 
(2-4)^2 * 1/3 + (4-4)^2 * 1/3 + (6-4)^2 * 1/3

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Re: [math] variance result

Posted by Phil Steitz <ph...@gmail.com>.
On 10/22/11 8:34 AM, entity@gmx.com wrote:
> I'm utterly sorry to pose such a dumb question, but:
>
> the variance of the values 2, 4, and 6: shouldn't that be 2.67 ? The StatUtils and DescriptveStatistics give me 4.
>
> My calculation (that I checked a dozen times) is: 
> (2-4)^2 * 1/3 + (4-4)^2 * 1/3 + (6-4)^2 * 1/3

The implementations in the classes above use the bias-corrected
formula for the variance, which makes the denominator above equal to
2.  If you want the non-bias-corrected version, you have to use the
Variance class directly and set the biasCorrected property to
false.  The javadoc could be clearer here and it would probably be
good to add a populationVariance method or a version of getVariance
in these classes that takes a boolean to determine whether or not
the result is bias-corrected.  I will open a JIRA for that.

Phil


>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
> For additional commands, e-mail: user-help@commons.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org