List of usage examples for org.apache.commons.math3.distribution TDistribution cumulativeProbability
public double cumulativeProbability(double x)
From source file:wsattacker.library.intelligentdos.success.TTestSuccessDecider.java
private double calculateProbability(Long[] run1, Long[] run2) { SummaryStatistics statisticsX = new SummaryStatistics(); for (double value : run1) { statisticsX.addValue(value);// w w w . j av a 2s .c o m } SummaryStatistics statisticsY = new SummaryStatistics(); for (double value : run2) { statisticsY.addValue(value); } // two-sample double t = TestUtils.t(statisticsX, statisticsY); long degreesOfFreedom = statisticsX.getN() + statisticsY.getN() - 2; // p-value = 0.3002 TDistribution tDistribution = new TDistribution(degreesOfFreedom); double pValue = tDistribution.cumulativeProbability(t); return pValue; }
From source file:wsattacker.plugin.intelligentdos.StatisticTest.java
private static void statistics(double[] x, double[] y) { DecimalFormat df = new DecimalFormat("#.######"); SummaryStatistics statisticsX = new SummaryStatistics(); for (double value : x) { statisticsX.addValue(value);//from w w w. ja va 2s. c o m } SummaryStatistics statisticsY = new SummaryStatistics(); for (double value : y) { statisticsY.addValue(value); } // t = -0.5331 double t = TestUtils.t(statisticsX, statisticsY); // df = 18 long degreesOfFreedom = statisticsX.getN() + statisticsY.getN() - 2; // p-value = 0.3002 TDistribution tDistribution = new TDistribution(degreesOfFreedom); double pValue = tDistribution.cumulativeProbability(t); // t = -0.5331, df = 18, p-value = 0.3002 System.out.print("t = " + df.format(t)); System.out.print(", df = " + degreesOfFreedom); System.out.println(", p-value = " + df.format(pValue)); System.out.println("mean of x mean of y"); System.out.println(df.format(statisticsX.getMean()) + " - " + df.format(statisticsY.getMean())); // Calculate 95% confidence interval double ci = calcMeanCI(statisticsY, 0.95); System.out.println(String.format("Confidence inteval 95%%: %f", ci)); }