Skip to content

Instantly share code, notes, and snippets.

View skaspi's full-sized avatar
🌅
DevOps Enthusiast :)

David skaspi

🌅
DevOps Enthusiast :)
  • Red Hat
  • Raanana
View GitHub Profile
@skaspi
skaspi / MovingAverage.java
Created January 6, 2019 12:12 — forked from jhalterman/MovingAverage.java
An exponentially weighted moving average implementation that decays based on the elapsed time since the last update, approximating a time windowed moving average.
/**
* An exponentially weighted moving average implementation that decays based on the elapsed time since the last update,
* approximating a time windowed moving average.
*/
public class MovingAverage {
private final long windowNanos;
// Mutable state
private volatile long lastNanos;
private volatile double average;