Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jettify/streamhist
https://github.com/jettify/streamhist
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/jettify/streamhist
- Owner: jettify
- License: apache-2.0
- Created: 2020-12-20T22:22:47.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-03-05T02:16:07.000Z (over 3 years ago)
- Last Synced: 2024-09-17T03:53:40.614Z (about 2 months ago)
- Language: Rust
- Size: 33.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StreamHist
[![ci-badge](https://github.com/jettify/streamhist/workflows/CI/badge.svg)](https://github.com/jettify/streamhist/actions?query=workflow%3ACI)
[![Crates.io](https://img.shields.io/crates/v/streamhist.svg)](https://crates.io/crates/streamhist)
[![Documentation](https://docs.rs/streamhist/badge.svg)](https://docs.rs/streamhist/)A rust implementation of a streaming centroid histogram algorithm found in
[Streaming Parallel Decision Trees](http://jmlr.org/papers/volume11/ben-haim10a/ben-haim10a.pdf)
paper by Ben-Haim/Tom-Tov.# Example
```rust
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 = (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