使用Apache Commons Math确定置信区间 [英] Using Apache Commons Math to determine confidence intervals

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

问题描述

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

I have a set of benchmark data for which I compute summary statistics using Apache Math Commons. Now I want to use the package to compute confidence intervals for the arithmetic means of e.g. running time measurements.

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

Is this possible at all? I am convinced that the package supports this, however I am at a loss about where to start.

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

This is the solution I ended up using with the help of Brent Worden's suggestion:

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没有直接支持构建置信区间。但是,它确实拥有计算它们所需的一切。

Apache Commons Math does not have direct support for constructing confidence intervals. However, it does have everything needed to compute them.

首先,使用 SummaryStatistics ,或其他一些StatisticalSummary 实施,将您的数据汇总成样本统计数据。

First, use SummaryStatistics, or some other StatisticalSummary implementation to summarize your data into sample statistics.

接下来,使用 TDistribution 来计算您想要的关键值信心水平。可以从摘要统计' n 属性中推断出自由度。

Next, use TDistribution to compute critical values for your desired confidence level. The degrees of freedom can be inferred from the summary statistics' n property.

最后,使用 mean variance n 摘要统计信息中的属性值来自分布的临界值,以计算您的置信下限和上限。

Last, use the mean, variance, and n property values from the summary statistics and the t critical value from the distribution to compute your lower and upper confidence limits.

这篇关于使用Apache Commons Math确定置信区间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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