Class SampleMeanVar
java.lang.Object
math.SampleMeanVar
- Author:
- Federico Granata
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new instance of SampleMeanVarSampleMeanVar(double[] data) Creates a new instance of SampleMeanVar calculating the parameters with the initializing data sequence -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcalcMean(double newValue) computes the new mean using a more stable algorithmprotected voidcalcVar(double newValue) computes the new sample variance using a stable algorithm it also computes the mean with the stable algorithm.doublegetConfInt(double perc) get the actual conf int it is 0 if the variance has not been calculateddoublegetMax()get the greatest valuedoublegetMean()get the sample meandoublegetMin()get the smallest valuedoublegetVar()get the sample variancevoidinitialize a new SampleMeanVar with parameters all zerovoidputNewSample(double newValue) update the sample mean & variance with the new value it uses stable algorithmstoString()creates a string with the calculated parameters of the sequence monitored by SampleMeanVar
-
Field Details
-
sum
protected double sum -
smean
protected double smean -
svar
protected double svar -
n
protected double n -
max
protected double max -
min
protected double min -
S
protected double S -
confInt
protected double confInt
-
-
Constructor Details
-
SampleMeanVar
public SampleMeanVar()Creates a new instance of SampleMeanVar -
SampleMeanVar
public SampleMeanVar(double[] data) 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()initialize a new SampleMeanVar with parameters all zero -
putNewSample
public void putNewSample(double newValue) update the sample mean & variance with the new value it uses stable algorithms- Parameters:
newValue-
-
calcMean
protected void calcMean(double newValue) computes the new mean using a more stable algorithm- Parameters:
newValue- the new element to be added to the sequence
-
calcVar
protected void calcVar(double newValue) 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 sequence
-
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
-
getConfInt
public double getConfInt(double perc) get the actual conf int it is 0 if the variance has not been calculated- Parameters:
perc- the percentile required- Returns:
- the confidence interval requested
-
toString
-