3 releases
0.0.1-alpha.3 | Feb 5, 2021 |
---|---|
0.0.1-alpha.2 | Jan 15, 2021 |
0.0.1-alpha.1 | Jan 9, 2021 |
#1815 in Data structures
27KB
470 lines
StreamHist
A rust implementation of a streaming centroid histogram algorithm found in Streaming Parallel Decision Trees paper by Ben-Haim/Tom-Tov.
Example
use rand::SeedableRng;
use rand_distr::{Distribution, Normal};
use rand_isaac::Isaac64Rng;
use streamhist::StreamingHistogram;
fn main() {
let mut rng = Isaac64Rng::seed_from_u64(42);
let dist = Normal::new(2.0, 3.0).unwrap();
let mut hist = StreamingHistogram::new(32);
let maxn = 10000;
let vals: Vec<f64> = (0..maxn).map(|_| dist.sample(&mut rng)).collect();
for v in vals.iter() {
hist.insert_one(*v);
}
println!("------------------------------------------------");
println!("Est Mean {:?}", hist.mean().unwrap());
println!("Est Var {:?}", hist.var().unwrap());
println!("Est Median {:?}", hist.median().unwrap());
println!("Est Count vals <= 2.0 {:?}", hist.count_less_then_eq(2.0));
println!("Est quantile {:?}", hist.quantile(0.75).unwrap());
println!("Min {:?}", hist.min().unwrap());
println!("Max {:?}", hist.max().unwrap());
println!("Count {:?}", hist.count());
println!("------------------------------------------------");
assert_eq!(hist.count(), maxn);
}
Lincese
Licensed under the Apache License, Version 2.0
Dependencies
~160KB