1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//!# online-statistics
//!
//! `online-statistics` is crate for Blazingly fast, generic and serializable online statistics.
//!
//!## Quickstart
//! Let's compute the online median and then serialize it:
//!```
//!use online_statistics::quantile::Quantile;
//!use online_statistics::stats::Univariate;
//!let data = vec![9., 7., 3., 2., 6., 1., 8., 5., 4.];
//!let mut running_median: Quantile<f64> = Quantile::new(0.5_f64).unwrap();
//!for x in data.iter() {
//! running_median.update(*x as f64); // update the current statistics
//! println!("The actual median value is: {}", running_median.get());
//!}
//!assert_eq!(running_median.get(), 5.0);
//!
//!// Convert the statistic to a JSON string.
//!let serialized = serde_json::to_string(&running_median).unwrap();
//!
//!// Convert the JSON string back to a statistic.
//!let deserialized: Quantile<f64> = serde_json::from_str(&serialized).unwrap();
//!
//!```
//!
//!## Installation
//!Add the following line to your `cargo.toml`:
//!```bash
//![dependencies]
//! online-statistics = "0.1.0"
//!```
//!## Statistics available
//!| Statistics | Revertable ?|
//!|---------------------------------|----------|
//!| 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`](https://github.com/online-ml/river) library in `Python` greatly inspired this crate.