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

这篇博客介绍了如何利用Apache Commons Math库计算基于样本统计的置信区间,特别是针对算术平均数的运行时间测量。首先,使用SummaryStatistics类对数据进行总结,然后利用TDistribution计算所需置信水平的关键值。最后,结合样本的均值、方差和大小来确定置信限。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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.

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 does not have direct support for constructing confidence intervals. However, it does have everything needed to compute them.

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

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.

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值