1   package org.djutils.math.means;
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  
14  public class ArithmeticMean<V extends Number, W extends Number> extends AbstractMean<ArithmeticMean<V, W>, V, W>
15  {
16      @Override
17      public final double getMean()
18      {
19          return getSum() / getSumOfWeights();
20      }
21  
22      @Override
23      public final ArithmeticMean<V, W> addImpl(final V value, final Number weight)
24      {
25          increment(weight.doubleValue() * value.doubleValue(), weight.doubleValue());
26          return this;
27      }
28  
29      @Override
30      public final String toString()
31      {
32          return "ArithmeticMean [current sum=" + getSum() + ", current sum of weights=" + getSumOfWeights()
33                  + ", current arithmetic mean=" + getMean() + "]";
34      }
35  
36  }