使用 Apache Commons Math 确定置信区间

2024-01-25

我有一组基准数据,我使用 Apache Math Commons 计算汇总统计数据。现在我想使用该包来计算算术平均值的置信区间,例如运行时间测量。

这有可能吗?我确信该软件包支持这一点,但是我不知道从哪里开始。

这是我在 Brent Worden 建议的帮助下最终使用的解决方案:

private double getConfidenceIntervalWidth(StatisticalSummary statistics, double significance) {
    TDistribution tDist = new TDistribution(statistics.getN() - 1);
    double a = tDist.inverseCumulativeProbability(1.0 - significance / 2);
    return a * statistics.getStandardDeviation() / Math.sqrt(statistics.getN());
}

Apache Commons Math 不直接支持构建置信区间。然而,它确实拥有计算它们所需的一切。

首先,使用摘要统计 http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/stat/descriptive/SummaryStatistics.html,或其他一些统计汇总 http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/stat/descriptive/StatisticalSummary.html实施将您的数据汇总为样本统计数据。

接下来,使用分布 http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/distribution/TDistribution.html计算所需置信水平的临界值。自由度可以从汇总统计中推断出来n财产。

最后,使用mean, variance, and n来自汇总统计的属性值和来自分布的 t 临界值来计算置信下限和上限。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

使用 Apache Commons Math 确定置信区间 的相关文章

随机推荐