java – 使用Apache Commons Math来确定置信区间

我有一套基准数据,我使用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没有直接支持构建置信区间.然而,它确实有一切需要计算它们.

首先,使用SummaryStatistics或其他一些其他StatisticalSummary实现来将您的数据汇总到样本统计数据中.

接下来,使用TDistribution计算所需置信度的临界值.自由度可以从总结统计资料n推断.

最后,使用摘要统计信息中的均值,方差和n个属性值以及来自分布的t临界值来计算您的下限和上限置信限.

相关文章

最近看了一下学习资料,感觉进制转换其实还是挺有意思的,尤...
/*HashSet 基本操作 * --set:元素是无序的,存入和取出顺序不...
/*list 基本操作 * * List a=new List(); * 增 * a.add(inde...
/* * 内部类 * */ 1 class OutClass{ 2 //定义外部类的成员变...
集合的操作Iterator、Collection、Set和HashSet关系Iterator...
接口中常量的修饰关键字:public,static,final(常量)函数...