Online statistics in Rust 🦀
watermill is crate 🦀 for Blazingly fast, generic and serializable online statistics.
Quickstart
Let's compute the online median and then serialize it:
use Quantile;
use Univariate;
let data: = vec!;
let mut running_median: = new.unwrap;
for x in data.into_iter
assert_eq!;
// Convert the statistic to a JSON string.
let serialized = to_string.unwrap;
// Convert the JSON string back to a statistic.
let deserialized: = from_str.unwrap;
Now let's compute the online sum using the iterators:
use IterStatisticsExtend;
let data: = vec!;
let vec_true: = vec!;
for in data.into_iter.online_sum.zip
You can also compute rolling statistics; in the following example let's compute the rolling sum on 2 previous data:
use Rolling;
use Univariate;
use Variance;
let data: = vec!;
let mut running_var: = default;
// We wrap `running_var` inside the `Rolling` struct.
let mut rolling_var: = new.unwrap;
for x in data.into_iter
assert_eq!;
Installation
Add the following line to your cargo.toml:
[dependencies]
watermill = "0.1.0"
Statistics available
| Statistics | Rollable ? |
|---|---|
| Mean | ✅ |
| Variance | ✅ |
| Sum | ✅ |
| Min | ✅ |
| Max | ✅ |
| Count | ❌ |
| Quantile | ✅ |
| Peak to peak | ✅ |
| Exponentially weighted mean | ❌ |
| Exponentially weighted variance | ❌ |
| Interquartile range | ✅ |
| Kurtosis | ❌ |
| Skewness | ❌ |
| Covariance | ❌ |
Inspiration
The stats module of the river library in Python greatly inspired this crate.