Max extends AbstractStorelessUnivariateStatistic implements Serializable { @Override public double evaluate(final double[] values, final int begin, final int length) throws MathIllegalArgumentException { double max = Double.NaN; if (test(values, begin, length)) { max = values[begin]; for (int i = begin; i < begin + length; i++) { if (!Double.isNaN(values[i])) { max = (max > values[i]) ? max : values[i]; } } } return max; } Max();  Max(Max original); @Override void increment(final double d); @Override void clear(); @Override double getResult(); long getN(); @Override double evaluate(final double[] values, final int begin, final int length); @Override Max copy(); static void copy(Max source, Max dest);  }
@Test public void testNaNs() { Max max = new Max(); double nan = Double.NaN; Assert.assertEquals(3d, max.evaluate(new double[]{nan, 2d, 3d}), 0); Assert.assertEquals(3d, max.evaluate(new double[]{1d, nan, 3d}), 0); Assert.assertEquals(2d, max.evaluate(new double[]{1d, 2d, nan}), 0); Assert.assertTrue(Double.isNaN(max.evaluate(new double[]{nan, nan, nan}))); }