Class RunningWeightedStatistics

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

public class RunningWeightedStatistics extends UnivariateStatistics
Calculate running statistics using weighted averaging
  • Field Details

    • asymptoticWeight

      protected final double asymptoticWeight
      weight for new samples
    • asymptoticPopulation

      protected final int asymptoticPopulation
      population 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 class UnivariateStatistics
      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 class UnivariateStatistics
      Returns:
      the sample variance of the mean