Class ExponentialMovingAverage


  • public class ExponentialMovingAverage
    extends java.lang.Object
    Provides an Exponential moving average of some value.
    • Constructor Summary

      Constructors 
      Constructor Description
      ExponentialMovingAverage​(double initialValue, double newSampleWeight, boolean sqrtWeighting)
      Creates a new value to track.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double addNewSample​(double newSample)
      Adds a new sample to the moving average and returns the updated value.
      double getCurrentValue()
      Returns the current moving average.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • ExponentialMovingAverage

        public ExponentialMovingAverage​(double initialValue,
                                        double newSampleWeight,
                                        boolean sqrtWeighting)
        Creates a new value to track.
        Parameters:
        initialValue - The value to be used as the initial average
        newSampleWeight - The fractional weight to give to new samples. 0.0 - 1.0 (exclusive)
        sqrtWeighting - If the samples should be weighted according to the square root to reduce the impact of outliers.
    • Method Detail

      • getCurrentValue

        public double getCurrentValue()
        Returns the current moving average.
        Returns:
        Double indicating the current moving average.
      • addNewSample

        public double addNewSample​(double newSample)
        Adds a new sample to the moving average and returns the updated value.
        Parameters:
        newSample - the new value to be added
        Returns:
        Double indicating the updated moving average value after adding a new sample.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object