streamhist

Crates.iostreamhist
lib.rsstreamhist
version0.0.1-alpha.3
sourcesrc
created_at2021-01-09 21:59:41.317349
updated_at2021-02-05 23:06:53.441857
descriptionImplementation of streaming histogram
homepagehttps://github.com/jettify/streamhist
repositoryhttps://github.com/jettify/streamhist.git
max_upload_size
id337236
size45,634
Nikolay Novik (jettify)

documentation

README

StreamHist

ci-badge Crates.io Documentation

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

Commit count: 26

cargo fmt