#metrics #statistics

exponential-decay-histogram

A histogram which exponentially weights in favor of recent values

6 releases

0.1.5 Jul 18, 2019
0.1.4 Mar 13, 2019
0.1.3 Nov 14, 2018
0.1.2 Sep 13, 2018
0.1.0 May 30, 2017

#197 in Data structures

Download history 51/week @ 2019-07-03 80/week @ 2019-07-10 131/week @ 2019-07-17 107/week @ 2019-07-24 62/week @ 2019-07-31 40/week @ 2019-08-07 40/week @ 2019-08-14 61/week @ 2019-08-21 66/week @ 2019-08-28 55/week @ 2019-09-04 47/week @ 2019-09-11 55/week @ 2019-09-18 55/week @ 2019-09-25 48/week @ 2019-10-02 47/week @ 2019-10-09

348 downloads per month
Used in 1 crate

MIT/Apache

19KB
334 lines

exponential-decay-histogram

CircleCI

Documentation

A histogram which exponentially weights in favor of recent values.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

A histogram which exponentially weights in favor of recent values.

Histograms compute statistics about the distribution of values in a data set. This histogram exponentially favors recent values over older ones, making it suitable for use cases such as monitoring the state of long running processes.

The histogram does not store all values simultaneously, but rather a randomized subset. This allows us to put bounds on overall memory use regardless of the rate of events.

This implementation is based on the ExponentiallyDecayingReservoir class in the Java Metrics library, which is itself based on the forward decay model described in Cormode et al. 2009.

Examples

use exponential_decay_histogram::ExponentialDecayHistogram;

# fn do_work() -> i64 { 0 }
let mut histogram = ExponentialDecayHistogram::new();

// Do some work for a while and fill the histogram with some information.
// Even though we're putting 10000 values into the histogram, it will only
// retain a subset of them.
for _ in 0..10000 {
    let size = do_work();
    histogram.update(size);
}

// Take a snapshot to inspect the current state of the histogram.
let snapshot = histogram.snapshot();
println!("count: {}", snapshot.count());
println!("min: {}", snapshot.min());
println!("max: {}", snapshot.max());
println!("mean: {}", snapshot.mean());
println!("standard deviation: {}", snapshot.stddev());
println!("median: {}", snapshot.value(0.5));
println!("99th percentile: {}", snapshot.value(0.99));

Dependencies

~560KB