commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Warren Tang <warren.c.t...@gmail.com>
Subject [math] SummaryStatistics.setVarianceImpl Usage
Date Sun, 16 Oct 2011 13:54:49 GMT
Hello, everyone

I'm trying to get a "population standard deviation
<http://commons.apache.org/math/api-1.2/org/apache/commons/math/stat/descriptive/moment/StandardDeviation.html>"
(non-bias-corrected) from SummaryStatistics.

This is what I did:

SummaryStatistics stats = new SummaryStatistics();
stats.setVarianceImpl(new Variance(false)); //use "population variance"
( sum((x_i - mean)^2) / n )
for(int i : scores) {
stats.addValue(i);
}
double sd = stats.getStandardDeviation();

However, the value of "sd" is "NaN". How can I do it correctly?

-- 
Regards,
Warren Tang <http://blog.tangcs.com>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message