@Test public void testDecrement() { IntegerWeightedMean mean = new IntegerWeightedMean(); for (int i = 1; i <= 5; i++) { mean.increment(1.0 / (i + 1), i); } mean.decrement(1.0 / 6.0, 5); mean.decrement(1.0 / 5.0, 4); assertEquals(3, mean.getN()); assertEquals((1.0 / 2.0 + 2.0 / 3.0 + 3.0 / 4.0) / 6.0, mean.getResult()); mean.increment(1.0 / 6.0, 5); mean.increment(1.0 / 5.0, 4); assertEquals(5, mean.getN()); assertEquals((1.0 / 2.0 + 2.0 / 3.0 + 3.0 / 4.0 + 4.0 / 5.0 + 5.0 / 6.0) / 15.0, mean.getResult()); }
public void decrement(double datum, long weight) { Preconditions.checkArgument(weight >= 0); Preconditions.checkState(count > 0); totalWeight -= weight; count--; mean -= ((double) weight / totalWeight) * (datum - mean); }
IntegerWeightedMean extends AbstractStorelessUnivariateStatistic implements Serializable { public void decrement(double datum, long weight) { Preconditions.checkArgument(weight >= 0); Preconditions.checkState(count > 0); totalWeight -= weight; count--; mean -= ((double) weight / totalWeight) * (datum - mean); } }
IntegerWeightedMean extends AbstractStorelessUnivariateStatistic implements Serializable { public void decrement(double datum, long weight) { Preconditions.checkArgument(weight >= 0); Preconditions.checkState(count > 0); totalWeight -= weight; count--; mean -= ((double) weight / totalWeight) * (datum - mean); } IntegerWeightedMean(); private  IntegerWeightedMean(long count, long totalWeight, double mean); }
IntegerWeightedMean extends AbstractStorelessUnivariateStatistic implements Serializable { public void decrement(double datum, long weight) { Preconditions.checkArgument(weight >= 0); Preconditions.checkState(count > 0); totalWeight -= weight; count--; mean -= ((double) weight / totalWeight) * (datum - mean); } IntegerWeightedMean(); private  IntegerWeightedMean(long count, long totalWeight, double mean); @Override IntegerWeightedMean copy(); @Override void clear(); @Override double getResult(); @Override long getN(); @Override void increment(double datum); void increment(double datum, long weight); void decrement(double datum, long weight); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object o); }
IntegerWeightedMean extends AbstractStorelessUnivariateStatistic implements Serializable { public void decrement(double datum, long weight) { Preconditions.checkArgument(weight >= 0); Preconditions.checkState(count > 0); totalWeight -= weight; count--; mean -= ((double) weight / totalWeight) * (datum - mean); } IntegerWeightedMean(); private  IntegerWeightedMean(long count, long totalWeight, double mean); @Override IntegerWeightedMean copy(); @Override void clear(); @Override double getResult(); @Override long getN(); @Override void increment(double datum); void increment(double datum, long weight); void decrement(double datum, long weight); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object o);  }