Skip to main content

hampel

Function hampel 

Source
pub fn hampel(values: &[f64], half: usize, threshold: f64) -> Vec<f64>
Expand description

The Hampel filter: each sample more than threshold robust standard deviations from its window’s median replaced by that median, the scale being 1.4826 times the window’s median absolute deviation (R. K. Pearson et al., The Class of Generalized Hampel Filters, EUSIPCO 2015, §2, eqs. 1 and 2, with K = half and t = threshold). Windows are cut short at the ends and skip NaNs, as in running_median, which is this filter at threshold = 0.

hpr reads heights after running_median instead (see MEDIAN_WINDOW_S); this is here to show why: a pulse among other large departures, as an ejection charge’s is, widens its own window’s spread until the filter keeps it.