StatisticsUtilities { public static double tValue(int runs) { if(runs == 1) throw new IllegalArgumentException("A t-value with 0 degrees of freedom cannot be computed"); else if(runs == 2) return 12.706; else if(runs == 3) return 4.303; else if(runs == 4) return 3.182; else if(runs == 5) return 2.776; else if(runs == 6) return 2.571; else if(runs == 7) return 2.447; else if(runs == 8) return 2.365; else if(runs == 9) return 2.306; else if(runs == 10) return 2.262; else if(runs == 11) return 2.228; else if(runs == 12) return 2.201; else if(runs == 13) return 2.179; else if(runs == 14) return 2.160; else if(runs == 15) return 2.145; else if(runs == 16) return 2.131; else if(runs == 17) return 2.120; else if(runs == 18) return 2.110; else if(runs == 19) return 2.101; else if(runs == 20) return 2.093; else if(runs == 21) return 2.086; else if(runs == 22) return 2.080; else if(runs == 23) return 2.074; else if(runs == 24) return 2.069; else if(runs == 25) return 2.064; else if(runs == 26) return 2.060; else if(runs == 27) return 2.056; else if(runs == 28) return 2.052; else if(runs == 29) return 2.048; else if(runs == 30) return 2.045; else throw new UnsupportedOperationException("Still need to expand tValue method to support different values of N: " + runs); }  static double percentile(final double[] values, final double p); static double median(double[] xs); static int argmax(double[] xs); static int argmax(int[] xs); @SuppressWarnings("unchecked") static int argmax(int[] xs, int rank); static int argmin(double[] xs); static int argmin(int[] xs); static int softmax(double[] ps, double temperature); static int probabilistic(double[] ps); static double[] distribution(double[] raw); static double[] distribution(int[] raw); static double mode(double[] xs); static double mode(double[] xs, double epsilon); static double maximum(double[] xs); static int maximum(Collection<Integer> xs); static long maximum(long[] xs); static double minimum(double[] xs); static double average(double[] xs); static int sum(int[] vals); static double sum(double[] vals); static int sum(Collection<Integer> xs); static double sumDouble(Collection<Double> xs); static double populationStandardDeviation(double[] xs); static double sampleStandardDeviation(double[] xs); static double populationVariance(double[] xs); static double sampleVariance(double[] xs); static double sumOfSquares(double[] xs); static double instantaneousErrorEnergy(double desired, double output); static double instantaneousTotalErrorEnergy(ArrayList<Pair<Double, Double>> pairs); static double averageSquaredErrorEnergy(ArrayList<ArrayList<Pair<Double, Double>>> samples); static double tValue(int runs);  }
@Test public void testTValue() { assertEquals(StatisticsUtilities.tValue(29), 2.048, ERROR); assertEquals(StatisticsUtilities.tValue(24), 2.069, ERROR); assertEquals(StatisticsUtilities.tValue(2), 12.706, ERROR); assertEquals(StatisticsUtilities.tValue(13), 2.179, ERROR); assertEquals(StatisticsUtilities.tValue(7), 2.447, ERROR); }