StatisticsUtilities { public static double mode(double[] xs) { return mode(xs, 0.001); }  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 testModeDoubleArray() { assertEquals(StatisticsUtilities.mode(new double[] { 1, 1, 1, 2, 2, 2, 3, 4, 5, 6, 7, 8, 8, 8, 8, 8, 8, 9 }), 8.0, ERROR); assertEquals(StatisticsUtilities.mode(new double[] { 1, 1, 1 }), 1, ERROR); assertEquals(StatisticsUtilities.mode(new double[] { 2, 1, 2, 1, 2, 1 }), 2, ERROR); assertEquals(StatisticsUtilities.mode(new double[] { 2, 3, 1, 3, 2, 3, 1, 3, 2, 3, 1, 3 }), 3, ERROR); assertEquals(StatisticsUtilities.mode(new double[] { 20, 20.2, 1.0, 1.05, 1.05, 2, 4.5 }), 1.05, ERROR); }
@Test public void testModeDoubleArrayDouble() { assertEquals(StatisticsUtilities.mode(new double[] { 1, 1, 1 }, 0.001), 1, ERROR); assertEquals(StatisticsUtilities.mode(new double[] { 1, 1, 1 }, 0.1), 1, ERROR); assertEquals(StatisticsUtilities.mode(new double[] { 1, 1.01, 1.01, 1.01 }, 0.1), 1.0, ERROR); assertEquals(StatisticsUtilities.mode(new double[] { 1, 1.01, 1.01, 1.01 }, 0.01), 1.01, ERROR); assertEquals(StatisticsUtilities.mode(new double[] { 20, 20.2, 1.0, 1.05, 1.05, 2, 4.5 }, 0.1), 1.0, ERROR); assertEquals(StatisticsUtilities.mode(new double[] { 20, 20.2, 1.0, 1.05, 1.05, 2, 4.5 }, 0.01), 1.05, ERROR); }