Class MovingAverageArrayFunction

All Implemented Interfaces:
EventListener, DoubleSource, UpdatableSource

public class MovingAverageArrayFunction extends AbstractArrayFunction implements DoubleSource
This class computes the average of the last given number of values in an array taken from a data source. The mean function return always a double value, so it implements the DoubleSource interface and the standard DoubleSource one.
  • Field Details

    • mean

      protected double mean
    • window

      protected int window
  • Constructor Details

    • MovingAverageArrayFunction

      public MovingAverageArrayFunction(@NonNull @NonNull IntArraySource source, int windowSize)
      Creates a count function on an integer array source.
      Parameters:
      source - The data source.
      Throws:
      NullPointerException - when source is null.
      IllegalArgumentException - when windowSize is < 1.
    • MovingAverageArrayFunction

      public MovingAverageArrayFunction(@NonNull @NonNull LongArraySource source, int windowSize)
      Creates a count function on a long array source.
      Parameters:
      source - The data source.
      Throws:
      NullPointerException - when source is null.
      IllegalArgumentException - when windowSize is < 1.
    • MovingAverageArrayFunction

      public MovingAverageArrayFunction(@NonNull @NonNull DoubleArraySource source, int windowSize)
      Create a count function on a double array source.
      Parameters:
      source - The data source.
      Throws:
      NullPointerException - when source is null.
      IllegalArgumentException - when windowSize is < 1.
  • Method Details

    • apply

      public void apply(double @NonNull [] data)
      Applies the function to the given array of double values.
      Overrides:
      apply in class AbstractArrayFunction
      Parameters:
      data - A source array of values.
      Throws:
      NullPointerException - when data is null.
    • apply

      public void apply(int @NonNull [] data)
      Applies the function to the given array of integer values.
      Overrides:
      apply in class AbstractArrayFunction
      Parameters:
      data - A source array of values.
      Throws:
      NullPointerException - when data is null.
    • apply

      public void apply(long @NonNull [] data)
      Applies the function to the given array of long values.
      Overrides:
      apply in class AbstractArrayFunction
      Parameters:
      data - A source array of values.
      Throws:
      NullPointerException - when data is null.
    • getDoubleValue

      public double getDoubleValue(@NonNull @NonNull Enum<?> variableID)
      Returns the double value corresponding to the given variableID
      Specified by:
      getDoubleValue in interface DoubleSource
      Parameters:
      variableID - A unique identifier for a variable.
      Returns:
      The current double value of the required variable.
      Throws:
      NullPointerException - when data is null.