com.aelitis.azureus.core.util.average
Class AverageFactory

java.lang.Object
  extended by com.aelitis.azureus.core.util.average.AverageFactory

public abstract class AverageFactory
extends java.lang.Object

Generates different types of averages.


Nested Class Summary
static interface AverageFactory.LazyMovingImmediateAverageAdapter<T>
           
static class AverageFactory.LazyMovingImmediateAverageState
           
 
Constructor Summary
AverageFactory()
           
 
Method Summary
static ExponentialMovingAverage ExponentialMovingAverage(float weight)
          Create an exponential moving average, with the given smoothing weight.
static ExponentialMovingAverage ExponentialMovingAverage(int periods)
          Create an exponential moving average, smoothing over the given number of periods, using a default smoothing weight value of 2/(1 + periods).
static
<T> long
LazyMovingImmediateAverage(int periods, int interval_secs, AverageFactory.LazyMovingImmediateAverageAdapter<T> adapter, T instance)
           
static
<T> long
LazySmoothMovingImmediateAverage(AverageFactory.LazyMovingImmediateAverageAdapter<T> adapter, T instance)
          Creates an auto-updating immediate moving average that will auto-deactivate average maintenance when values are not being extracted from it, auto-reactivate when required etc.
static MovingAverage MovingAverage(int periods)
          Create a moving average, that moves over the given number of periods.
static MovingImmediateAverage MovingImmediateAverage(int periods)
          Create a moving average, that moves over the given number of periods and gives immediate results (i.e.
static RunningAverage RunningAverage()
          Create a simple running average.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AverageFactory

public AverageFactory()
Method Detail

RunningAverage

public static RunningAverage RunningAverage()
Create a simple running average.


MovingAverage

public static MovingAverage MovingAverage(int periods)
Create a moving average, that moves over the given number of periods.


MovingImmediateAverage

public static MovingImmediateAverage MovingImmediateAverage(int periods)
Create a moving average, that moves over the given number of periods and gives immediate results (i.e. after the first update of X the average will be X


ExponentialMovingAverage

public static ExponentialMovingAverage ExponentialMovingAverage(int periods)
Create an exponential moving average, smoothing over the given number of periods, using a default smoothing weight value of 2/(1 + periods).


ExponentialMovingAverage

public static ExponentialMovingAverage ExponentialMovingAverage(float weight)
Create an exponential moving average, with the given smoothing weight. Larger weigths (closer to 1.0) will give more influence to recent data and smaller weights (closer to 0.00) will provide smoother averaging (give more influence to older data).


LazySmoothMovingImmediateAverage

public static <T> long LazySmoothMovingImmediateAverage(AverageFactory.LazyMovingImmediateAverageAdapter<T> adapter,
                                                        T instance)
Creates an auto-updating immediate moving average that will auto-deactivate average maintenance when values are not being extracted from it, auto-reactivate when required etc.

Parameters:
periods -
adapter -
instance -
Returns:

LazyMovingImmediateAverage

public static <T> long LazyMovingImmediateAverage(int periods,
                                                  int interval_secs,
                                                  AverageFactory.LazyMovingImmediateAverageAdapter<T> adapter,
                                                  T instance)