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 void
addData(double... data)
Recompute the statistic with more data, incrementally if possible.void
addData(double[] data, double[] weights)
long
N()
Get the size of the sample.double
sumOfWeights()
double
value()
Get the value of the statistic.
-
-
-
Method Detail
-
addData
public void addData(double... data)
Description copied from interface:Statistic
Recompute the statistic with more data, incrementally if possible.
-
addData
public void addData(double[] data, double[] weights)
-
N
public long N()
Description copied from interface:Statistic
Get the size of the sample.
-
value
public double value()
Description copied from interface:Statistic
Get the value of the statistic.
-
sumOfWeights
public double sumOfWeights()
-
-