Class MeanVarianceArrayFunction

All Implemented Interfaces:
EventListener, DoubleSource, UpdatableSource

public class MeanVarianceArrayFunction extends AbstractArrayFunction implements DoubleSource
This class computes the average and variance value of an array of values taken from a data source. The mean function always returns double values, so it implements only the DoubleSource interface.
In order to retrieve the mean pass the MeanVarianceArrayFunction.Variables.MEAN argument to the getDoubleValue(Enum) function, while for the variance the MeanVarianceArrayFunction.Variables.VARIANCE one.
  • Field Details

    • mean

      protected double mean
    • variance

      protected double variance
  • Constructor Details

    • MeanVarianceArrayFunction

      public MeanVarianceArrayFunction(@NonNull @NonNull IntArraySource source)
      Creates a mean function on an integer array source.
      Parameters:
      source - The data source.
      Throws:
      NullPointerException - when source is null.
    • MeanVarianceArrayFunction

      public MeanVarianceArrayFunction(@NonNull @NonNull LongArraySource source)
      Creates a mean function on a long array source.
      Parameters:
      source - The data source.
      Throws:
      NullPointerException - when source is null.
    • MeanVarianceArrayFunction

      public MeanVarianceArrayFunction(@NonNull @NonNull DoubleArraySource source)
      Creates a mean function on a double array source.
      Parameters:
      source - The data source.
      Throws:
      NullPointerException - when source is null.
  • 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.