Class WeightedMeanVar
java.lang.Object
math.WeightedMeanVar
- Author:
- Stefano Omini
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleprotected doubleprotected doubleprotected doubleprotected doubleprotected doubleprotected double -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of SampleMeanVarWeightedMeanVar(double[] data, double[] weight) Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequence -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcalcMeanAndVar(double newValue, double newWeight) computes the new sample variance using a stable algorithm it also computes the mean with the stable algorithm.doublegetMax()get the greatest valuedoublegetMean()get the sample meandoublegetMin()get the smallest valuedoublegetVar()get the sample variancevoidCreates a new instance of SampleMeanVarvoidinitialize(double[] data, double[] weight) Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequencevoidputNewSample(double newValue, double newWeight) update the sample mean & variance with the new value it uses stable algorithms
-
Field Details
-
mean
protected double mean -
var
protected double var -
max
protected double max -
min
protected double min -
expectedValueX2
protected double expectedValueX2 -
sumWeights
protected double sumWeights -
sumSamples
protected double sumSamples
-
-
Constructor Details
-
WeightedMeanVar
public WeightedMeanVar()Creates a new instance of SampleMeanVar -
WeightedMeanVar
public WeightedMeanVar(double[] data, double[] weight) Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequence- Parameters:
data- the initial data sequence;
-
-
Method Details
-
initialize
public void initialize()Creates a new instance of SampleMeanVar -
initialize
public void initialize(double[] data, double[] weight) Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequence- Parameters:
data- the initial data sequence;weight- the weight
-
putNewSample
public void putNewSample(double newValue, double newWeight) update the sample mean & variance with the new value it uses stable algorithms- Parameters:
newValue-newWeight- the new weight
-
calcMeanAndVar
protected void calcMeanAndVar(double newValue, double newWeight) computes the new sample variance using a stable algorithm it also computes the mean with the stable algorithm.- Parameters:
newValue- the new element to be added to the sequencenewWeight- the new weight
-
getMean
public double getMean()get the sample mean- Returns:
- the actual sample mean
-
getVar
public double getVar()get the sample variance- Returns:
- the actual sample variance
-
getMax
public double getMax()get the greatest value- Returns:
- the actual max value
-
getMin
public double getMin()get the smallest value- Returns:
- the actual min value
-