Java – use Apache commons math to determine confidence intervals

I have a set of benchmark data. I use Apache math commons to calculate summary statistics Now I want to use the package to calculate, for example, the confidence interval of the arithmetic mean of the data Run time measurement

Is this possible? I believe the package supports this, but I failed from where I started

This is the solution I finally used as suggested by 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());
}

Solution

Apache commons math does not directly support building confidence intervals However, it does have everything to calculate them

First, use summarystatistics or some other statisticalsummary implementation to summarize your data into sample statistics

Next, use tDISTRIBUTION to calculate the critical value of the required confidence Degrees of freedom can be inferred from summary statistics n

Finally, calculate your lower and upper confidence limits using the mean, variance and N attribute values in the summary statistics and the t-critical value from the distribution

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>