Top Description Fields Constructors Methods
io.rsocket.loadbalance

pack-priv Class Ewma

extends Object
Class Inheritance
Imports
io.rsocket.util.Clock, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.AtomicLongFieldUpdater

Compute the exponential weighted moving average of a series of values. The time at which you insert the value into `Ewma` is used to compute a weight (recent points are weighted higher). The parameter for defining the convergence speed (like most decay process) is the half-life.

e.g. with a half-life of 10 unit, if you insert 100 at t=0 and 200 at t=10 the ewma will be equal to (200 - 100)/2 = 150 (half of the distance between the new and the old value)

Field Summary

Modifier and TypeField and Description
pack-priv volatile double
pack-priv volatile long
pack-priv static final AtomicLongFieldUpdater<Ewma>
pack-priv final long

Constructor Summary

AccessConstructor and Description
public
Ewma(long halfLife, TimeUnit unit, double initialValue)

Method Summary

Modifier and TypeMethod and Description
public synchronized void
insert(double x)

public synchronized void
reset(double value)

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public double
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

ewmaback to summary
pack-priv volatile double ewma
stampback to summary
pack-priv volatile long stamp
STAMPback to summary
pack-priv static final AtomicLongFieldUpdater<Ewma> STAMP
tauback to summary
pack-priv final long tau

Constructor Detail

Ewmaback to summary
public Ewma(long halfLife, TimeUnit unit, double initialValue)

Method Detail

insertback to summary
public synchronized void insert(double x)
resetback to summary
public synchronized void reset(double value)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
valueback to summary
public double value()