hampel

Crates.iohampel
lib.rshampel
version0.2.0
sourcesrc
created_at2022-05-11 02:52:39.640591
updated_at2024-07-20 14:15:36.327593
descriptionSequential outlier detection and removal using Hampel identifiers
homepagehttps://github.com/HamaguRe/hampel.git
repositoryhttps://github.com/HamaguRe/hampel.git
max_upload_size
id584303
size157,991
HamaguRe (HamaguRe)

documentation

README

hampel

Sequential outlier detection and removal using Hampel identifiers.

It supports f32 and f64.

Usage

Add this to your Cargo.toml:

[dependencies]
hampel = "0.2"
#features = ["extrapolation"]  <-- At your option

extrapolation feature

When this feature is enabled, linear extrapolated values are returned when outliers are detected. If not enabled, the median value of the window is returned.

Example

use hampel::Window;

fn main() {
    // Window size: 5 (>= 3)
    // Initialization value of window: 0.0
    // Threshold: Median of the window ±3σ.
    let mut filter = Window::<f64, 5>::new(0.0, 3.0);
    
    let input_vals = [0.0; 100];  // <- Containing outliers
    let mut filtered_vals = [0.0; 100];
    for (i, val) in input_vals.iter().enumerate() {
        filtered_vals[i] = filter.update(*val);
    }
    // filtered_vals <-- Outliers have been removed
}

Sample images

sample1

sample2

License

Licensed under either of Apache License, Version 2.0 or MIT License at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 2

cargo fmt