Package com.badlogic.gdx.math
Class WindowedMean
- java.lang.Object
-
- com.badlogic.gdx.math.WindowedMean
-
public final class WindowedMean extends java.lang.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 Summary
Constructors Constructor Description WindowedMean(int window_size)
constructor, window_size specifies the number of samples we will continuously get the mean and variance from.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addValue(float value)
adds a new sample to this mean.void
clear()
clears this WindowedMean.float
getHighest()
float
getLatest()
float
getLowest()
float
getMean()
returns the mean of the samples added to this instance.float
getOldest()
int
getValueCount()
int
getWindowSize()
float[]
getWindowValues()
boolean
hasEnoughData()
float
standardDeviation()
-
-
-
Constructor Detail
-
WindowedMean
public WindowedMean(int window_size)
constructor, window_size 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 window_size values have been added.- Parameters:
window_size
- size of the sample window
-
-
Method Detail
-
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.
-
addValue
public void addValue(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
-
getMean
public float getMean()
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
-
getOldest
public float getOldest()
- Returns:
- the oldest value in the window
-
getLatest
public float getLatest()
- Returns:
- the value last added
-
standardDeviation
public float standardDeviation()
- Returns:
- The standard deviation
-
getLowest
public float getLowest()
-
getHighest
public float getHighest()
-
getValueCount
public int getValueCount()
-
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.
-
-