Package xal.tools.statistics
Class RunningWeightedStatistics
java.lang.Object
xal.tools.statistics.UnivariateStatistics
xal.tools.statistics.RunningWeightedStatistics
Calculate running statistics using weighted averaging
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final int
population beyond which we should use the asymptotic weightprotected final double
weight for new samplesFields inherited from class xal.tools.statistics.UnivariateStatistics
mean, meanSquare, population
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSample
(double value) Add a new sample measurement.void
clear()
Clear the samplesprotected final double
Get the current weight.protected final double
getWeight
(double population) Get the weight to apply to the next new sample given the specified population.double
Get the variance of the mean from the actual value assuming the supporting data is a random subset of all the data.double
Get the variance of the mean from the actual value.Methods inherited from class xal.tools.statistics.UnivariateStatistics
mean, meanSquare, population, sampleStandardDeviation, sampleStandardDeviationOfMean, sampleVariance, standardDeviation, standardDeviationOfMean, variance
-
Field Details
-
asymptoticWeight
protected final double asymptoticWeightweight for new samples -
asymptoticPopulation
protected final int asymptoticPopulationpopulation beyond which we should use the asymptotic weight
-
-
Constructor Details
-
RunningWeightedStatistics
public RunningWeightedStatistics(double weight) Constructor- Parameters:
weight
- asymptotic weight to apply to new samples in large populations
-
-
Method Details
-
clear
public void clear()Clear the samples -
getWeight
protected final double getWeight()Get the current weight.- Returns:
- the current weight
-
getWeight
protected final double getWeight(double population) Get the weight to apply to the next new sample given the specified population. When we first start adding samples, we must trust the newest samples most and gradually shift trust to the older samples. Ultimately we will trust new samples at least at the asymptotic weight. -
addSample
public void addSample(double value) Add a new sample measurement.- Parameters:
value
- The new sample measurement
-
varianceOfMean
public double varianceOfMean()Get the variance of the mean from the actual value.- Overrides:
varianceOfMean
in classUnivariateStatistics
- Returns:
- the variance of the mean from the actual value
-
sampleVarianceOfMean
public double sampleVarianceOfMean()Get the variance of the mean from the actual value assuming the supporting data is a random subset of all the data.- Overrides:
sampleVarianceOfMean
in classUnivariateStatistics
- Returns:
- the sample variance of the mean
-