libgdx API

com.badlogic.gdx.math
Class WindowedMean

java.lang.Object
  extended by 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.

Author:
badlogicgames@gmail.com

Constructor Summary
WindowedMean(int window_size)
          constructor, window_size specifies the number of samples we will continuously get the mean and variance from.
 
Method Summary
 void addValue(float value)
          adds a new sample to this mean.
 void clear()
          clears this WindowedMean.
 float getLatest()
           
 float getMean()
          returns the mean of the samples added to this instance.
 float getOldest()
           
 boolean hasEnoughData()
           
 float standardDeviation()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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:
wheter the value returned will be meaningfull

clear

public void clear()
clears this WindowedMean. The class will only return meaningfull 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 meaningfull 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

libgdx API

Copyright 2010 Mario Zechner (contact@badlogicgames.com), Nathan Sweet (admin@esotericsoftware.com)