Class AbstractStatistics.SMA

  • Enclosing class:
    AbstractStatistics

    public static class AbstractStatistics.SMA
    extends java.lang.Object
    Simple Moving Average
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private double average  
      private int length  
      private double sum  
      private java.util.LinkedList<java.lang.Double> values  
    • Constructor Summary

      Constructors 
      Constructor Description
      SMA​(int length)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double compute​(double value)
      Compute the moving average.
      double currentAverage()  
      • Methods inherited from class java.lang.Object

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

      • values

        private java.util.LinkedList<java.lang.Double> values
      • length

        private int length
      • sum

        private double sum
      • average

        private double average
    • Constructor Detail

      • SMA

        public SMA​(int length)
        Parameters:
        length - the maximum length
    • Method Detail

      • currentAverage

        public double currentAverage()
      • compute

        public double compute​(double value)
        Compute the moving average. Synchronised so that no changes in the underlying data is made during calculation.
        Parameters:
        value - The value
        Returns:
        The average