Apache Commons Math的标准差 [英] Standard deviation with Apache Commons Math

查看:1005
本文介绍了Apache Commons Math的标准差的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache Commons Math计算向量的SD.问题:我得到的值与手动值不同

I am computing the SD of a vector using Apache Commons Math. The problem: I get different values than by hand

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

例如,取值[1699.0、1819.0、1699.0、1719.0、1689.0、1709.0、1819.0、1689.0]. SD应该为52.067,但Commons Math = 55.662.

E.g., 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.

我在做什么错了?

推荐答案

Apache StandardDeviation 类可用于计算两个值:标准偏差"和人口标准偏差".

The Apache StandardDeviation class can be used for computing both values: "Standard Deviation" and "Population Standard deviation".

用于计算第二个值的初始化

For computing the second value initialize it with

    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

这篇关于Apache Commons Math的标准差的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆