Class MutableUnivariateStatistics

java.lang.Object
xal.tools.statistics.UnivariateStatistics
xal.tools.statistics.MutableUnivariateStatistics

public class MutableUnivariateStatistics extends UnivariateStatistics
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
  • Constructor Details

    • MutableUnivariateStatistics

      public MutableUnivariateStatistics()
      Constructor with no samples.
    • MutableUnivariateStatistics

      public MutableUnivariateStatistics(UnivariateStatistics stats)
      Copy constructor
      Parameters:
      stats - the statistics to copy
    • MutableUnivariateStatistics

      public MutableUnivariateStatistics(UnivariateStatistics stats, double scale)
      Constructor which scales the samples from an existing set of statistics.
      Parameters:
      stats - the statistics against which to scale
      scale - 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 samples
      average - the mean
      averageSquare - 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

      public void addSamples(UnivariateStatistics stats)
      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 replace
      newValue - 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