Class MovingImmediateAverage

  • All Implemented Interfaces:
    Average

    public class MovingImmediateAverage
    extends java.lang.Object
    implements Average
    Implements a basic moving average.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double[] data  
      private int periods  
      private int pos  
      private double total  
    • Constructor Summary

      Constructors 
      Constructor Description
      MovingImmediateAverage​(int periods)
      Create a new moving average.
    • Field Detail

      • periods

        private final int periods
      • data

        private double[] data
      • pos

        private int pos
      • total

        private double total
    • Constructor Detail

      • MovingImmediateAverage

        public MovingImmediateAverage​(int periods)
        Create a new moving average.
    • Method Detail

      • 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
      • getValues

        public double[] getValues()
      • getAverage

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

        public int getPeriods()
      • getSampleCount

        public int getSampleCount()
      • getSum

        public double getSum()
      • calculateAve

        private double calculateAve()