@Test public void testRange() { double expResult = 9.0d; double result = SampleStats.range(values, true); assertEquals(expResult, result, TOL); }
public static double range(Double[] values, boolean ignoreNaN) { if (values == null || values.length == 0) { return Double.NaN; } else if (values.length == 1) { return 0d; } SortedSet<Double> set = CollectionFactory.sortedSet(); set.addAll(Arrays.asList(values)); if (ignoreNaN) set.remove(Double.NaN); return set.last() - set.first(); }
SampleStats { public static double range(Double[] values, boolean ignoreNaN) { if (values == null || values.length == 0) { return Double.NaN; } else if (values.length == 1) { return 0d; } SortedSet<Double> set = CollectionFactory.sortedSet(); set.addAll(Arrays.asList(values)); if (ignoreNaN) set.remove(Double.NaN); return set.last() - set.first(); } }
SampleStats { public static double range(Double[] values, boolean ignoreNaN) { if (values == null || values.length == 0) { return Double.NaN; } else if (values.length == 1) { return 0d; } SortedSet<Double> set = CollectionFactory.sortedSet(); set.addAll(Arrays.asList(values)); if (ignoreNaN) set.remove(Double.NaN); return set.last() - set.first(); }  }
SampleStats { public static double range(Double[] values, boolean ignoreNaN) { if (values == null || values.length == 0) { return Double.NaN; } else if (values.length == 1) { return 0d; } SortedSet<Double> set = CollectionFactory.sortedSet(); set.addAll(Arrays.asList(values)); if (ignoreNaN) set.remove(Double.NaN); return set.last() - set.first(); }  static double max(Double[] values, boolean ignoreNaN); static double mean(Double[] values, boolean ignoreNaN); static double min(Double[] values, boolean ignoreNaN); @SuppressWarnings("empty-statement") static double median(Double[] values, boolean ignoreNaN); @SuppressWarnings("empty-statement") static double mode(Double[] values, boolean ignoreNaN); static double range(Double[] values, boolean ignoreNaN); static double variance(Double[] values, boolean ignoreNaN); static double sdev(Double[] values, boolean ignoreNaN); static double sum(Double[] values, boolean ignoreNaN); }
SampleStats { public static double range(Double[] values, boolean ignoreNaN) { if (values == null || values.length == 0) { return Double.NaN; } else if (values.length == 1) { return 0d; } SortedSet<Double> set = CollectionFactory.sortedSet(); set.addAll(Arrays.asList(values)); if (ignoreNaN) set.remove(Double.NaN); return set.last() - set.first(); }  static double max(Double[] values, boolean ignoreNaN); static double mean(Double[] values, boolean ignoreNaN); static double min(Double[] values, boolean ignoreNaN); @SuppressWarnings("empty-statement") static double median(Double[] values, boolean ignoreNaN); @SuppressWarnings("empty-statement") static double mode(Double[] values, boolean ignoreNaN); static double range(Double[] values, boolean ignoreNaN); static double variance(Double[] values, boolean ignoreNaN); static double sdev(Double[] values, boolean ignoreNaN); static double sum(Double[] values, boolean ignoreNaN);  }