online-statistics
is crate 🦀 for Blazingly fast, generic and serializable online statistics.
Let's compute the online median and then serialize it:
```rust
use onlinestatistics::quantile::Quantile;
use onlinestatistics::stats::Univariate;
let data: Vec
// Convert the statistic to a JSON string. let serialized = serdejson::tostring(&running_median).unwrap();
// Convert the JSON string back to a statistic.
let deserialized: Quantile
Now let's compute the online sum using the iterators:
rust
use onlinestatistics::iter::IterStatisticsExtend;
let data: Vec
You can also compute rolling statistics; in the following example let's compute the rolling sum on 2 previous data: ```rust
use onlinestatistics::rolling::Rolling;
use onlinestatistics::stats::Univariate;
use onlinestatistics::variance::Variance;
let data: Vecrunning_var
inside the Rolling
struct.
let mut rollingvar: Rolling
Add the following line to your cargo.toml
:
[dependencies]
online-statistics = "0.2.1"
| Statistics | Rollable ?| |--------------------------------- |---------- | | Mean | ✅ | | Variance | ✅ | | Sum | ✅ | | Min | ✅ | | Max | ✅ | | Count | ❌ | | Quantile | ✅ | | Peak to peak | ✅ | | Exponentially weighted mean | ❌ | | Exponentially weighted variance | ❌ | | Interquartile range | ✅ | | Kurtosis | ❌ | | Skewness | ❌ | | Covariance | ❌ |
The stats
module of the river
library in Python
greatly inspired this crate.