【问题标题】:Calculating Skewness and kurtosis with apache commons使用 apache commons 计算偏度和峰度
【发布时间】:2013-03-28 00:55:29
【问题描述】:

我在向量中有数据点,我想计算数据集的偏度和峰度。

如何使用 apache commons 解决这个问题?

Vector<Double> mydata = new Vector<Double>
//data points are added by my routing

我在文档中找到的代码是这样的:

    FourthMoment m4 = new FourthMoment();
    Mean m = new Mean(m4);
    Variance v = new Variance(m4);
    Skewness s= new Skewness(m4);
    Kurtosis k = new Kurtosis(m4);
    assertEquals(var,v.getResult(),tolerance);
    assertEquals(skew ,s.getResult(),tolerance);

但是我的编译器无法识别 Fourthmoment。以及我如何实际获取其中的 mydata?

感谢您的帮助,我似乎无法获得清晰的示例。

我使用 3.1.1 版,它可以识别我的所有导入,除了第一个:

import org.apache.commons.math3.stat.descriptive.moment.FourthMoment;
import org.apache.commons.math3.stat.descriptive.moment.Kurtosis;
import org.apache.commons.math3.stat.descriptive.moment.Mean;
import org.apache.commons.math3.stat.descriptive.moment.Skewness;
import org.apache.commons.math3.stat.descriptive.moment.Variance;

【问题讨论】:

  • 它应该能识别FourthMoment。 apache commons 是什么版本的?
  • 3.1.1,我刚下载了。它识别我所有的导入,但不是第一个(我编辑了问题)
  • 我需要这个第四时刻吗?或者我可以根据我的向量计算它吗?
  • @NPE 是的,这很奇怪,ThirdMoment 也不存在,只有 SecondMoment。 3.1.1 的 javadoc 确实在 Kurtosis 描述甚至代码清单中都引用了它,但它没有显示为文档中的类条目。

标签: java math statistics apache-commons


【解决方案1】:

我需要这个第四时刻吗?或者我可以根据我的向量计算它吗?

我想你可以直接计算,使用Kurtosis.evaluate()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-16
    • 2019-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-27
    • 2019-04-05
    • 2020-06-21
    相关资源
    最近更新 更多