/** * Returns the <a href="http://en.wikipedia.org/wiki/Arithmetic_mean">arithmetic mean</a> of * {@code values}. * * <p>If these values are a sample drawn from a population, this is also an unbiased estimator of * the arithmetic mean of the population. * * @param values a nonempty series of values, which will be converted to {@code double} values * (this may cause loss of precision) * @throws IllegalArgumentException if {@code values} is empty or contains any non-finite value * @deprecated Use {@link Stats#meanOf} instead, noting the less strict handling of non-finite * values. */ @Deprecated // com.google.common.math.DoubleUtils @GwtIncompatible public static double mean(Iterable<? extends Number> values) { return mean(values.iterator()); }
/** * Returns the <a href="http://en.wikipedia.org/wiki/Arithmetic_mean">arithmetic mean</a> of * {@code values}. * * <p>If these values are a sample drawn from a population, this is also an unbiased estimator of * the arithmetic mean of the population. * * @param values a nonempty series of values, which will be converted to {@code double} values * (this may cause loss of precision) * @throws IllegalArgumentException if {@code values} is empty or contains any non-finite value * @deprecated Use {@link Stats#meanOf} instead, noting the less strict handling of non-finite * values. */ @Deprecated // com.google.common.math.DoubleUtils @GwtIncompatible public static double mean(Iterable<? extends Number> values) { return mean(values.iterator()); }
/** * Returns the <a href="http://en.wikipedia.org/wiki/Arithmetic_mean">arithmetic mean</a> of * {@code values}. * * <p>If these values are a sample drawn from a population, this is also an unbiased estimator of * the arithmetic mean of the population. * * @param values a nonempty series of values, which will be converted to {@code double} values * (this may cause loss of precision) * @throws IllegalArgumentException if {@code values} is empty or contains any non-finite value * @deprecated Use {@link Stats#meanOf} instead, noting the less strict handling of non-finite * values. */ @Deprecated // com.google.common.math.DoubleUtils @GwtIncompatible public static double mean(Iterable<? extends Number> values) { return mean(values.iterator()); }
@GwtIncompatible // DoubleMath.mean public void testMean_longIterator() { assertEquals( -13.75, DoubleMath.mean(ImmutableList.of(11L, -22L, 44L, -88L).iterator()), 1.0e-10); assertEquals(11, DoubleMath.mean(ImmutableList.of(11L).iterator()), 1.0e-10); try { DoubleMath.mean(ImmutableList.<Long>of().iterator()); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@GwtIncompatible // DoubleMath.mean public void testMean_intIterable() { assertEquals(-13.75, DoubleMath.mean(ImmutableList.of(11, -22, 44, -88)), 1.0e-10); assertEquals(11, DoubleMath.mean(ImmutableList.of(11)), 1.0e-10); try { DoubleMath.mean(ImmutableList.<Integer>of()); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@GwtIncompatible // DoubleMath.mean public void testMean_intIterator() { assertEquals(-13.75, DoubleMath.mean(ImmutableList.of(11, -22, 44, -88).iterator()), 1.0e-10); assertEquals(11, DoubleMath.mean(ImmutableList.of(11).iterator()), 1.0e-10); try { DoubleMath.mean(ImmutableList.<Integer>of().iterator()); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@GwtIncompatible // DoubleMath.mean public void testMean_longIterable() { assertEquals(-13.75, DoubleMath.mean(ImmutableList.of(11L, -22L, 44L, -88L)), 1.0e-10); assertEquals(11, DoubleMath.mean(ImmutableList.of(11L)), 1.0e-10); try { DoubleMath.mean(ImmutableList.<Long>of()); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@GwtIncompatible // DoubleMath.mean public void testMean_doubleVarargs() { assertEquals(-1.375, DoubleMath.mean(1.1, -2.2, 4.4, -8.8), 1.0e-10); assertEquals(1.1, DoubleMath.mean(1.1), 1.0e-10); try { DoubleMath.mean(Double.NaN); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } try { DoubleMath.mean(Double.POSITIVE_INFINITY); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@GwtIncompatible // DoubleMath.mean public void testMean_doubleIterable() { assertEquals(-1.375, DoubleMath.mean(ImmutableList.of(1.1, -2.2, 4.4, -8.8)), 1.0e-10); assertEquals(1.1, DoubleMath.mean(ImmutableList.of(1.1)), 1.0e-10); try { DoubleMath.mean(ImmutableList.<Double>of()); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } try { DoubleMath.mean(ImmutableList.of(Double.NaN)); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } try { DoubleMath.mean(ImmutableList.of(Double.POSITIVE_INFINITY)); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@GwtIncompatible // DoubleMath.mean public void testMean_emptyVarargs() { try { DoubleMath.mean(); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@Override public void runActionOnPoll() { long now = System.currentTimeMillis(); List<Long> toRemove = statusUpdateDeltas.keySet().stream() .filter((e) -> e < now - 30000) .collect(Collectors.toList()); toRemove.forEach(statusUpdateDeltas::remove); if (statusUpdateDeltas.isEmpty()) { statusUpdateDelta30sAverage.set(0L); } else { statusUpdateDelta30sAverage.set((long) DoubleMath.mean(statusUpdateDeltas.values())); } } }
private static double nanmean(final Collection<Double> values) { final List<Double> finiteValues = values.stream().filter(Double::isFinite).collect(Collectors.toList()); if (finiteValues.isEmpty()) return Double.NaN; return DoubleMath.mean(finiteValues); }
@GwtIncompatible // DoubleMath.mean public void testMean_intIterator() { assertEquals(-13.75, DoubleMath.mean(ImmutableList.of(11, -22, 44, -88).iterator()), 1.0e-10); assertEquals(11, DoubleMath.mean(ImmutableList.of(11).iterator()), 1.0e-10); try { DoubleMath.mean(ImmutableList.<Integer>of().iterator()); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@GwtIncompatible // DoubleMath.mean public void testMean_longIterator() { assertEquals(-13.75, DoubleMath.mean(ImmutableList.of(11L, -22L, 44L, -88L).iterator()), 1.0e-10); assertEquals(11, DoubleMath.mean(ImmutableList.of(11L).iterator()), 1.0e-10); try { DoubleMath.mean(ImmutableList.<Long>of().iterator()); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@GwtIncompatible // DoubleMath.mean public void testMean_intIterable() { assertEquals(-13.75, DoubleMath.mean(ImmutableList.of(11, -22, 44, -88)), 1.0e-10); assertEquals(11, DoubleMath.mean(ImmutableList.of(11)), 1.0e-10); try { DoubleMath.mean(ImmutableList.<Integer>of()); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@GwtIncompatible // DoubleMath.mean public void testMean_emptyVarargs() { try { DoubleMath.mean(); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }