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