APIdia Launch Partner
Top Description Fields Constructors Methods
com.badlogic.gdx.math

public final Class WindowedMean

extends Object
Class Inheritance

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.
Author
[email protected]

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv boolean
pack-priv int
pack-priv float
pack-priv float[]

Constructor Summary

AccessConstructor and Description
public
WindowedMean(int
size of the sample window
window_size
)

constructor, window_size specifies the number of samples we will continuously get the mean and variance from.

Method Summary

Modifier and TypeMethod and Description
public void
addValue(float
The value to add
value
)

adds a new sample to this mean.

public void
clear()

clears this WindowedMean.

public float
public float
getLatest()

Returns: the value last added

public float
public float

Returns:

the mean
getMean
()

returns the mean of the samples added to this instance.

public float
getOldest()

Returns: the oldest value in the window

public int
public int
public float[]
getWindowValues()

Returns: A new float[] containing all values currently in the window of the stream, in order from oldest to latest.

public boolean
hasEnoughData()

Returns: whether the value returned will be meaningful

public float
standardDeviation()

Returns: The standard deviation

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

added_valuesback to summary
pack-priv int added_values
dirtyback to summary
pack-priv boolean dirty
last_valueback to summary
pack-priv int last_value
meanback to summary
pack-priv float mean
valuesback to summary
pack-priv float[] values

Constructor Detail

WindowedMeanback to summary
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:int

size of the sample window

Method Detail

addValueback to summary
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:float

The value to add

clearback to summary
public void clear()

clears this WindowedMean. The class will only return meaningful values after enough data has been added again.

getHighestback to summary
public float getHighest()
getLatestback to summary
public float getLatest()
Returns:float

the value last added

getLowestback to summary
public float getLowest()
getMeanback to summary
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:float

the mean

getOldestback to summary
public float getOldest()
Returns:float

the oldest value in the window

getValueCountback to summary
public int getValueCount()
getWindowSizeback to summary
public int getWindowSize()
getWindowValuesback to summary
public float[] getWindowValues()
Returns:float[]

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.

hasEnoughDataback to summary
public boolean hasEnoughData()
Returns:boolean

whether the value returned will be meaningful

standardDeviationback to summary
public float standardDeviation()
Returns:float

The standard deviation