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