@Test public void testVariance() { Assertions.assertThat(StatisticsMath.variance(Arrays.asList(42, 42, 42))).isEqualTo(0); Assertions.assertThat(StatisticsMath.variance(Arrays.asList(43, 42, 41))).isEqualTo(2.0 / 3.0); }
public static <T extends Number> double variance(final List<T> values) { double mu = mean(values); List<Number> val2 = new ArrayList<>(values.size()); for (Number f : values) { double diff = f.doubleValue() - mu; val2.add(diff * diff); } return mean(val2); }
StatisticsMath { public static <T extends Number> double variance(final List<T> values) { double mu = mean(values); List<Number> val2 = new ArrayList<>(values.size()); for (Number f : values) { double diff = f.doubleValue() - mu; val2.add(diff * diff); } return mean(val2); } }
StatisticsMath { public static <T extends Number> double variance(final List<T> values) { double mu = mean(values); List<Number> val2 = new ArrayList<>(values.size()); for (Number f : values) { double diff = f.doubleValue() - mu; val2.add(diff * diff); } return mean(val2); } @SuppressWarnings("unused") private  StatisticsMath(); }
StatisticsMath { public static <T extends Number> double variance(final List<T> values) { double mu = mean(values); List<Number> val2 = new ArrayList<>(values.size()); for (Number f : values) { double diff = f.doubleValue() - mu; val2.add(diff * diff); } return mean(val2); } @SuppressWarnings("unused") private  StatisticsMath(); static double mean(final List<T> values); static double median(final List<T> values); static double variance(final List<T> values); static double std(final List<T> values); }
StatisticsMath { public static <T extends Number> double variance(final List<T> values) { double mu = mean(values); List<Number> val2 = new ArrayList<>(values.size()); for (Number f : values) { double diff = f.doubleValue() - mu; val2.add(diff * diff); } return mean(val2); } @SuppressWarnings("unused") private  StatisticsMath(); static double mean(final List<T> values); static double median(final List<T> values); static double variance(final List<T> values); static double std(final List<T> values);  }