Class MovingAverager

java.lang.Object
com.treemap.swing.voronoi.MovingAverager

public class MovingAverager extends Object
Class for calculating a moving average.
  • Constructor Details

    • MovingAverager

      public MovingAverager(int nValues)
      Creates a new MovingAverager.
      Parameters:
      nValues - number of values to use for the moving average
  • Method Details

    • add

      public void add(double value)
      Adds a new value to the ring buffer.
      Parameters:
      value - the new value
    • getAverage

      public double getAverage()
      Calculates and returns the average of the proviously added values. Maximal number of previous values are defined by the initial nValues parameter of the contructor.
      Returns:
      the average value