@Test public void testMean() { Assertions.assertThat(StatisticsMath.mean(Arrays.asList(1))).isEqualTo(1); Assertions.assertThat(StatisticsMath.mean(Arrays.asList(1, 1))).isEqualTo(1); Assertions.assertThat(StatisticsMath.mean(Arrays.asList(1, 1, 1))).isEqualTo(1); Assertions.assertThat(StatisticsMath.mean(Arrays.asList(42, 42, 42))).isEqualTo(42); Assertions.assertThat(StatisticsMath.mean(Arrays.asList(42, 0))).isEqualTo(21); Assertions.assertThat(StatisticsMath.mean(Arrays.asList(-1, 1, 1, -1))).isEqualTo(0); Assertions.assertThat(StatisticsMath.mean(Arrays.asList(1, 2, 3, 4, 5, 6))).isCloseTo(21.0 / 6.0, Assertions.withinPercentage(0.01)); }
public static <T extends Number> double mean(final List<T> values) { double sum = 0; for (Number f : values) { sum += f.doubleValue(); } return sum / values.size(); }
StatisticsMath { public static <T extends Number> double mean(final List<T> values) { double sum = 0; for (Number f : values) { sum += f.doubleValue(); } return sum / values.size(); } }
StatisticsMath { public static <T extends Number> double mean(final List<T> values) { double sum = 0; for (Number f : values) { sum += f.doubleValue(); } return sum / values.size(); } @SuppressWarnings("unused") private  StatisticsMath(); }
StatisticsMath { public static <T extends Number> double mean(final List<T> values) { double sum = 0; for (Number f : values) { sum += f.doubleValue(); } return sum / values.size(); } @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 mean(final List<T> values) { double sum = 0; for (Number f : values) { sum += f.doubleValue(); } return sum / values.size(); } @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);  }