netflix.ocelli.util.ExpAvg Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ocelli-core Show documentation
Show all versions of ocelli-core Show documentation
ocelli-core developed by Netflix
package netflix.ocelli.util;
public class ExpAvg implements Average {
private final double k;
private volatile double ema = 0;
public ExpAvg(int N) {
this.k = 2.0/(double)(N+1);
}
@Override
public synchronized void addSample(long sample) {
ema = sample * k + ema * (1-k);
}
@Override
public double get() {
return ema;
}
@Override
public synchronized void reset() {
ema = 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy