Standard deviation from Apache Commons Math

I compute SD vectors using Apache Commons Math. Problem: I get different values ​​than manually

DescriptiveStatistics stats = new DescriptiveStatistics();
stats.addValue(value1);
...
stats.addValue(value8);
stats.getStandardDeviation();

For example, take the values ​​[1699.0, 1819.0, 1699.0, 1719.0, 1689.0, 1709.0, 1819.0, 1689.0]. SD should be 52.067, but Commons Math = 55.662.

What am I doing wrong?

+5
source share
2 answers

Apache gives you a "standard deviation", but you are looking for a "standard deviation from the population"

Perhaps you could use getPopulationVariance()and then take the square root yourself? I do not see the functions for this in the DS library.

+5
source

Apache StandardDeviation : " " " ".

    StandardDeviation sd = new StandardDeviation(false);

:

    double[] v = {1.0, 2.0, 3.0, 4.0, 5.0};
    StandardDeviation sd = new StandardDeviation(false);
    sd.evaluate(v);
    // returns 1.414

    StandardDeviation sd2 = new StandardDeviation();
    sd2.evaluate(v);
    // returns 1.581
+6

All Articles