MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ HampelFilter()

template<typename T >
MayaFlux::Kinesis::HampelFilter< T >::HampelFilter ( size_t  window = 8,
double  threshold_mad = 3.5,
size_t  max_consecutive_rejections = 3 
)
inlineexplicit

Construct a filter.

Parameters
windowNumber of recent accepted samples to test new candidates against, minimum 3 since MAD needs at least a few points to be meaningful
threshold_madNumber of scaled-MAD units beyond which a candidate is rejected, typically 3.0 to 4.0
max_consecutive_rejectionsForces the next candidate to be accepted unconditionally, and clears history to restart the window from it, once this many candidates in a row have been rejected. Without this, a real sustained change in the signal (which any consecutive Differential reading during real motion looks like relative to an older, now-stale window) can never be re-accepted: once every recent candidate is rejected against a frozen median, the filter locks onto whatever value it last accepted and holds it indefinitely, since a rejected candidate is never added to the window that future candidates are tested against. Default 3, since three consecutive genuine outliers from the same underlying cause is already an unusual coincidence; more than that is far more likely to be a real change the window has fallen behind.

Definition at line 75 of file HampelFilter.hpp.

77 : m_history(window < 3 ? 3 : window)
78 , m_threshold_mad(threshold_mad)
79 , m_max_consecutive_rejections(max_consecutive_rejections)
80 , m_last_good(T {})
81 , m_has_history(false)
82 {
83 }
Memory::HistoryBuffer< T > m_history