Class ExponentialMovingAverage

java.lang.Object
com.biglybt.core.util.average.ExponentialMovingAverage
All Implemented Interfaces:
Average

public class ExponentialMovingAverage extends Object implements Average
Implements an exponential moving average.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private double
     
    private final float
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new exponential moving average, using the given smoothing rate weight.
    Create a new exponential moving average which smooths over the given number of periods.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Return average-so-far.
    void
    sets back to start-of-day
    double
    update(double newValue)
    Update average and return average-so-far.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • weight

      private final float weight
    • prevEMA

      private double prevEMA
  • Constructor Details

    • ExponentialMovingAverage

      public ExponentialMovingAverage(int periods)
      Create a new exponential moving average which smooths over the given number of periods.
    • ExponentialMovingAverage

      public ExponentialMovingAverage(float weight)
      Create a new exponential moving average, using the given smoothing rate weight.
  • Method Details

    • reset

      public void reset()
      Description copied from interface: Average
      sets back to start-of-day
      Specified by:
      reset in interface Average
    • update

      public double update(double newValue)
      Update average and return average-so-far.
      Specified by:
      update in interface Average
    • getAverage

      public double getAverage()
      Return average-so-far.
      Specified by:
      getAverage in interface Average