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