cz.cuni.amis.utils.statistic
Class MovingAverage<TYPE>

Package class diagram package MovingAverage
java.lang.Object
  extended by cz.cuni.amis.utils.statistic.MovingAverage<TYPE>
All Implemented Interfaces:
IMovingAverage<TYPE>

public class MovingAverage<TYPE>
extends Object
implements IMovingAverage<TYPE>


Constructor Summary
MovingAverage(IAveragator<TYPE> averagator)
           
 
Method Summary
 void add(TYPE item)
          Add another item into the moving average.
 TYPE getAverage()
          Returns an average of all items stored.
 int getCurrentLength()
          Return current number of items that are used to compute the average returned via IMovingAverage.getAverage().
 int getMaxLength()
          Return max number of consecutive items (added via IMovingAverage.add(Object) that are used to compute the average returned via IMovingAverage.getAverage().
 boolean isEnoughValues()
          Whether the object has enough values to compute the avarage according to the max numbers it may store (returns IMovingAverage.getCurrentLength() == IMovingAverage.getMaxLength().
 void reset()
          Resets the object -> it removes all items stored.
 void setMaxLength(int length)
          Sets number of items that the object requires for the computing of the average.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MovingAverage

public MovingAverage(IAveragator<TYPE> averagator)
Method Detail

add

public void add(TYPE item)
Description copied from interface: IMovingAverage
Add another item into the moving average.

Specified by:
add in interface IMovingAverage<TYPE>

getAverage

public TYPE getAverage()
Description copied from interface: IMovingAverage
Returns an average of all items stored.

Returns null if no values are stored.

Specified by:
getAverage in interface IMovingAverage<TYPE>
Returns:

getCurrentLength

public int getCurrentLength()
Description copied from interface: IMovingAverage
Return current number of items that are used to compute the average returned via IMovingAverage.getAverage().

Specified by:
getCurrentLength in interface IMovingAverage<TYPE>
Returns:

getMaxLength

public int getMaxLength()
Description copied from interface: IMovingAverage
Return max number of consecutive items (added via IMovingAverage.add(Object) that are used to compute the average returned via IMovingAverage.getAverage().

Specified by:
getMaxLength in interface IMovingAverage<TYPE>
Returns:

isEnoughValues

public boolean isEnoughValues()
Description copied from interface: IMovingAverage
Whether the object has enough values to compute the avarage according to the max numbers it may store (returns IMovingAverage.getCurrentLength() == IMovingAverage.getMaxLength().

Specified by:
isEnoughValues in interface IMovingAverage<TYPE>

reset

public void reset()
Description copied from interface: IMovingAverage
Resets the object -> it removes all items stored. The IMovingAverage.getAverage() will return null after the call.

Specified by:
reset in interface IMovingAverage<TYPE>

setMaxLength

public void setMaxLength(int length)
Description copied from interface: IMovingAverage
Sets number of items that the object requires for the computing of the average. (Note that computation is done all the time, but when there is enough items == set number, the IMovingAverage.isEnoughValues() reports true.)

Specified by:
setMaxLength in interface IMovingAverage<TYPE>


Copyright © 2015 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.