6 releases

0.2.3 Nov 11, 2021
0.2.2 Nov 16, 2019
0.2.1 Aug 15, 2019
0.1.1 Aug 15, 2019

#1302 in Algorithms

Download history 368/week @ 2024-07-23 1045/week @ 2024-07-30 1209/week @ 2024-08-06 573/week @ 2024-08-13 643/week @ 2024-08-20 448/week @ 2024-08-27 512/week @ 2024-09-03 426/week @ 2024-09-10 460/week @ 2024-09-17 483/week @ 2024-09-24 422/week @ 2024-10-01 362/week @ 2024-10-08 465/week @ 2024-10-15 848/week @ 2024-10-22 1608/week @ 2024-10-29 970/week @ 2024-11-05

3,918 downloads per month
Used in 4 crates

Apache-2.0

25KB
541 lines

T-Digest algorithm in rust

Build Status codecov

This implementation is following Facebook folly's implementation

Installation

Add this to your Cargo.toml:

[dependencies]
tdigest = "0.2"

then you are good to go. If you are using Rust 2015 you have to extern crate tdigest to your crate root as well.

Example

use tdigest::TDigest;

let t = TDigest::new_with_size(100);
let values: Vec<f64> = (1..=1_000_000).map(f64::from).collect();
let t = t.merge_sorted(values);
let ans = t.estimate_quantile(0.99);
let expected: f64 = 990_000.0;
let percentage: f64 = (expected - ans).abs() / expected;

assert!(percentage < 0.01);

lib.rs:

T-Digest algorithm in rust

Installation

Add this to your Cargo.toml:

[dependencies]
tdigest = "0.2"

then you are good to go. If you are using Rust 2015 you have to extern crate tdigest to your crate root as well.

Example

use tdigest::TDigest;

let t = TDigest::new_with_size(100);
let values: Vec<f64> = (1..=1_000_000).map(f64::from).collect();

let t = t.merge_sorted(values);

let ans = t.estimate_quantile(0.99);
let expected: f64 = 990_000.0;

let percentage: f64 = (expected - ans).abs() / expected;
assert!(percentage < 0.01);

Dependencies

~185–400KB