Package xal.tools.statistics
Class MutableUnivariateStatistics
java.lang.Object
xal.tools.statistics.UnivariateStatistics
xal.tools.statistics.MutableUnivariateStatistics
MutableUnivariateStatistics calculates statistics of a series of
measurements. The statistics can be updated with each additional measurement.
Only simple statistics are generated (mean and standard deviation).
- Author:
- tap
-
Field Summary
Fields inherited from class xal.tools.statistics.UnivariateStatistics
mean, meanSquare, population
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor with no samples.MutableUnivariateStatistics
(int size, double average, double averageSquare) Primary Constructor with a starting set of statistics.Copy constructorMutableUnivariateStatistics
(UnivariateStatistics stats, double scale) Constructor which scales the samples from an existing set of statistics. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSample
(double value) Add a new sample measurement.void
addSamples
(UnivariateStatistics stats) Merge in samples from other statistics.void
clear()
Clear the samplesvoid
removeSample
(double value) Remove a sample from the statisticsvoid
replaceSample
(double oldValue, double newValue) Replace an old sample with a fresh sample.void
scaleData
(double scale) Modify the statistics for data of another scale.Methods inherited from class xal.tools.statistics.UnivariateStatistics
mean, meanSquare, population, sampleStandardDeviation, sampleStandardDeviationOfMean, sampleVariance, sampleVarianceOfMean, standardDeviation, standardDeviationOfMean, variance, varianceOfMean
-
Constructor Details
-
MutableUnivariateStatistics
public MutableUnivariateStatistics()Constructor with no samples. -
MutableUnivariateStatistics
Copy constructor- Parameters:
stats
- the statistics to copy
-
MutableUnivariateStatistics
Constructor which scales the samples from an existing set of statistics.- Parameters:
stats
- the statistics against which to scalescale
- factor which is used to scale the copied statistics
-
MutableUnivariateStatistics
public MutableUnivariateStatistics(int size, double average, double averageSquare) Primary Constructor with a starting set of statistics.- Parameters:
size
- the number of samplesaverage
- the meanaverageSquare
- the mean square of the samples
-
-
Method Details
-
clear
public void clear()Clear the samples -
addSample
public void addSample(double value) Add a new sample measurement.- Parameters:
value
- The new sample measurement
-
addSamples
Merge in samples from other statistics.- Parameters:
stats
- the statistics which should be merged into these statistics
-
replaceSample
public void replaceSample(double oldValue, double newValue) Replace an old sample with a fresh sample. This is useful when updating statistics on circular buffers.- Parameters:
oldValue
- the sample measurement to replacenewValue
- the new sample measurement
-
removeSample
public void removeSample(double value) Remove a sample from the statistics- Parameters:
value
- the sample measurement to remove
-
scaleData
public void scaleData(double scale) Modify the statistics for data of another scale. For example, if you took data with one set of units but want results in another. This method should be used with caution as it changes the scale of the data and new data should only be added if it uses the new scale.- Parameters:
scale
- the amount by which to scale the existing sample measurements
-