This crate provides an abstraction to compute an exponential moving average over evenly or non-evenly spaced timeseries.
use ewma::{EWMA, Smoothing};
let datapoints: Vec<f64> = vec![10.3, 11.9, -1.33, 2.0];
// Apply an exponential moving average with alpha=0.5
// on a stream of evenly spaced values:
let mut risk = EWMA::new(0.6f64, Smoothing::Static);
for datapoint in datapoints.iter() {
risk.add(datapoint)
}
println!("risk score: {}", risk.value());
If your timeseries is evenly spaced, you can simply use a static smoothing factor (aka. "alpha"). Every value is aggregated into a metric of the form:
A weather station reports the local temperature every hour. We have a sample for every hour. The delay between two points is always one hour.
If the gap between two points varies,