StatisticsUtilities { public static double maximum(double[] xs) { double max = xs[0]; for (int i = 1; i < xs.length; i++) { max = Math.max(max, xs[i]); } return max; }  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 testMaximum() { double[] test = { 1, 1, 1, 12, 2, 2, 2, 23, 3, 3, 3, 500}; double ans = StatisticsUtilities.maximum(test); double[] test2 = { 1, 2, 3, 4, 5 }; double[] test5 = { 1, 50, 100 }; double[] test3 = { 1, 1, 100, 50 }; double[] test4 = { 1, 1, 1, 1 }; assertEquals(ans, 500, ERROR); assertEquals(StatisticsUtilities.maximum(test2), 5, ERROR); assertEquals(StatisticsUtilities.maximum(test5), 100, ERROR); assertEquals(StatisticsUtilities.maximum(test3), 100, ERROR); assertEquals(StatisticsUtilities.maximum(test4), 1, ERROR); }
@Test public void testMaximumCollectionOfInteger() { ArrayList<Integer> test = new ArrayList<Integer>(); test.add(1); test.add(2); test.add(3); test.add(4); test.add(5); assertEquals(StatisticsUtilities.maximum(test), 5); ArrayList<Integer> test2 = new ArrayList<Integer>(); test2.add(1); test2.add(50); test2.add(100); assertEquals(StatisticsUtilities.maximum(test2), 100, ERROR); test2.add(150); assertEquals(StatisticsUtilities.maximum(test2), 150, ERROR); }
@Test public void testMaximumLongArray() { long[] test1 = { 1, 2, 3, 4, 5 }; long[] test2 = { 1, Integer.MAX_VALUE, ((long) Integer.MAX_VALUE) + 1 }; assertEquals(StatisticsUtilities.maximum(test1), 5, ERROR); assertEquals(StatisticsUtilities.maximum(test2), ((long) Integer.MAX_VALUE) + 1 , ERROR); }