Class WeightedMean
- java.lang.Object
-
- dev.nm.stat.descriptive.moment.weighted.WeightedMean
-
- All Implemented Interfaces:
Statistic
public class WeightedMean extends Object implements Statistic
The weighted mean is defined as \[ \bar{x} = \frac{ \sum_{i=1}^N w_i x_i}{\sum_{i=1}^N w_i} \]- See Also:
- Wikipedia: Weighted mean
-
-
Constructor Summary
Constructors Constructor Description WeightedMean()WeightedMean(double[] data, double[] weights)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddData(double... data)Recompute the statistic with more data, incrementally if possible.voidaddData(double[] data, double[] weights)longN()Get the size of the sample.doublesumOfWeights()doublevalue()Get the value of the statistic.
-
-
-
Method Detail
-
addData
public void addData(double... data)
Description copied from interface:StatisticRecompute the statistic with more data, incrementally if possible.
-
addData
public void addData(double[] data, double[] weights)
-
N
public long N()
Description copied from interface:StatisticGet the size of the sample.
-
value
public double value()
Description copied from interface:StatisticGet the value of the statistic.
-
sumOfWeights
public double sumOfWeights()
-
-