I am using Apache Math3 to do a Student's t test for a website project. Suppose I have two samples:
double[] sampleOne = new double[] {134 ,146 ,104 ,119 ,124 ,161 ,107 ,83 ,113 ,129 ,97 ,123};
double[] sampleTwo = new double[] { 70, 118, 101, 85, 107, 132, 94};
This data is copied from https://www.statsdirect.com/help/parametric_methods/unpaired_t.htm
I hope to calculate the confidence interval as shown on the above page. For example:
Assuming equal variances
95% confidence interval for difference between means = -2.193679 to 40.193679
I found this SO link:
Using Apache Commons Math to determine confidence intervals, which shows this method:
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());
}
This seems not working for two samples in t tests. I did quite research, but was not able to find how to do it with Apache Math3.