smoothed_z_score

Crates.iosmoothed_z_score
lib.rssmoothed_z_score
version0.1.3
sourcesrc
created_at2017-11-10 21:48:46.329029
updated_at2017-11-10 21:48:46.329029
descriptionSmoothed z-score algo (very robust thresholding algorithm)
homepagehttps://github.com/swizard0/smoothed_z_score
repositoryhttps://github.com/swizard0/smoothed_z_score
max_upload_size
id38919
size6,787
wkt-publishers (github:georust:wkt-publishers)

documentation

README

Smoothed z-score peaks detector

Description

Rust implementation for Smoothed z-score algorithm.

Usage

Add this to your Cargo.toml:

[dependencies]
smoothed_z_score = "0.1"

and this to your crate root:

extern crate smoothed_z_score;

Example usage

Consider this dataset (from the original stackoverflow reply):

sample dataset

    use smoothed_z_score::{Peak, PeaksDetector, PeaksFilter};

    fn main() {
        let input = vec![
            1.0, 1.0, 1.1, 1.0, 0.9, 1.0, 1.0, 1.1, 1.0, 0.9, 1.0, 1.1, 1.0, 1.0, 0.9, 1.0, 1.0, 1.1, 1.0,
            1.0, 1.0, 1.0, 1.1, 0.9, 1.0, 1.1, 1.0, 1.0, 0.9, 1.0, 1.1, 1.0, 1.0, 1.1, 1.0, 0.8, 0.9, 1.0,
            1.2, 0.9, 1.0, 1.0, 1.1, 1.2, 1.0, 1.5, 1.0, 3.0, 2.0, 5.0, 3.0, 2.0, 1.0, 1.0, 1.0, 0.9, 1.0,
            1.0, 3.0, 2.6, 4.0, 3.0, 3.2, 2.0, 1.0, 1.0, 0.8, 4.0, 4.0, 2.0, 2.5, 1.0, 1.0, 1.0
        ];
        let output: Vec<_> = input
            .into_iter()
            .enumerate()
            .peaks(PeaksDetector::new(30, 5.0, 0.0), |e| e.1)
            .map(|((i, _), p)| (i, p))
            .collect();
        assert_eq!(output, vec![
            (45, Peak::High), (47, Peak::High), (48, Peak::High), (49, Peak::High),
            (50, Peak::High), (51, Peak::High), (58, Peak::High), (59, Peak::High),
            (60, Peak::High), (61, Peak::High), (62, Peak::High), (63, Peak::High),
            (67, Peak::High), (68, Peak::High), (69, Peak::High), (70, Peak::High),
        ]);
    }
Commit count: 6

cargo fmt