|
OSSIA
Open Scenario System for Interactive Application
|
Running median over the last N samples.
More...
Running median over the last N samples.
Unlike an average, this rejects isolated outliers outright, which is what one wants against the occasional bogus reading of a sensor or a tracker.
Kept as a chronological ring plus a sorted copy of the same window: an insert is a binary search and a small contiguous move, which for the window sizes this is meant for beats any heap-based scheme by a wide margin.
Public Types | |
| using | value_type = T |
Public Member Functions | |
| OSSIA_INLINE void | reset () noexcept |
| Forget the history: the next sample restarts the filter. | |
| OSSIA_INLINE void | assign_parameters (const median_filter &) noexcept |
| No runtime parameters: the window size is a template argument. | |
| OSSIA_INLINE T | operator() (T x) noexcept |
Public Attributes | |
| std::array< T, N > | history {} |
| Chronological ring of the window contents. | |
| std::array< T, N > | sorted {} |
| The same contents, kept sorted over the first count entries. | |
| std::uint32_t | head {} |
| Where the next sample goes in history. | |
| std::uint32_t | count {} |
| How many entries are valid, saturating at N. | |