Package arc.math

Class WindowedMean

java.lang.Object
arc.math.WindowedMean

public final class WindowedMean extends Object
A simple class keeping track of the mean of a stream of values within a certain window. the WindowedMean will only return a value in case enough data has been sampled. After enough data has been sampled the oldest sample will be replaced by the newest in case a new sample is added.
  • Constructor Details

    • WindowedMean

      public WindowedMean(int windowSize)
      constructor, windowSize specifies the number of samples we will continuously get the mean and variance from. the class will only return meaning full values if at least windowSize values have been added.
      Parameters:
      windowSize - size of the sample window
  • Method Details

    • reset

      public void reset()
    • get

      public float get(int index)
    • hasEnoughData

      public boolean hasEnoughData()
      Returns:
      whether the value returned will be meaningful
    • clear

      public void clear()
      clears this WindowedMean. The class will only return meaningful values after enough data has been added again.
    • fill

      public void fill(float value)
    • add

      public void add(float value)
      adds a new sample to this mean. In case the window is full the oldest value will be replaced by this new value.
      Parameters:
      value - The value to add
    • mean

      public float mean()
      returns the mean of the samples added to this instance. Only returns meaningful results when at least window_size samples as specified in the constructor have been added.
      Returns:
      the mean
    • rawMean

      public float rawMean()
      Returns:
      raw mean; can be used before this window has enough data.
    • oldest

      public float oldest()
      Returns:
      the oldest value in the window
    • latest

      public float latest()
      Returns:
      the value last added
    • standardDeviation

      public float standardDeviation()
      Returns:
      The standard deviation
    • lowest

      public float lowest()
    • highest

      public float highest()
    • getCount

      public int getCount()
    • getWindowSize

      public int getWindowSize()
    • getWindowValues

      public float[] getWindowValues()
      Returns:
      A new float[] containing all values currently in the window of the stream, in order from oldest to latest. The length of the array is smaller than the window size if not enough data has been added.