Class WeightedVariance
- java.lang.Object
-
- dev.nm.stat.descriptive.moment.weighted.WeightedVariance
-
- All Implemented Interfaces:
Statistic
public class WeightedVariance extends Object implements Statistic
The weighted sample variance is defined as follows. The biased sample variance is: \[ \sigma^2 = \frac{\sum_{i=1}^N w_i \left(x_i - \mu^*\right)^2 }{V_1} \] where \(V_1 = \sum_{i=1}^N w_i\) and \(\mu^*\) is the weighted mean. The unbiased sample variance is (assuming each \(x_i\) is drawn from a Gaussian distribution with variance \(1 / w_i\)): \[ s^2\ = \frac {V_1} {V_1^2-V_2} \sum_{i=1}^N w_i \left(x_i - \mu^*\right)^2 \] where \(V_2 = \sum_{i=1}^N {w_i^2}\).
-
-
Constructor Summary
Constructors Constructor Description WeightedVariance()
WeightedVariance(boolean unbiased)
WeightedVariance(double[] data, double[] weights)
WeightedVariance(double[] data, double[] weights, boolean unbiased)
-
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
stdev()
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.
-
stdev
public double stdev()
-
-