0
$\begingroup$

I am using a 3-pass cascaded moving average filter for smoothing noisy data. I applied some optimization algorithms to determine the optimal length of the MAF window.

For different amplitudes of data variation, I got different optimal window lengths.

Is it meaningful or applicable to implement an adaptive window size MAF for online data streams?

If so, how can I switch between different window sizes without causing spikes in filtered data or abrupt changes in the rate of the smoothed data?

$\endgroup$

1 Answer 1

1
$\begingroup$

yep, that's totally doable.

However, since you want to be able to adapt at any point, the simple "add newest, subtract oldest sample from sum" approach to moving averages might no longer work (you'd need to be able to subtract or add more or fewer samples on the fly, which might require you to recalculate the whole sum, within one sample). At that point, the MA loses its computational advantage.

If so, how can I switch between different window sizes without causing spikes in filtered data or abrupt changes in the rate of the smoothed data?

Interpolate between the old and the new filter impulse response, and cycle through the interpolated filters slowly enough for you to avoid what you define to be a spike. You can't mathematically have "no abrupt change" but "abruptly change". That's the point where your Moving Average really needs to be treated as any other direct form FIR filter.

So: why a moving average? Unless you're really looking for a filter with a sinc spectrum, that's rarely the most adequate smoothing filter. And through your interpolation requirements, you lose most of the computational advantage of a simple moving average implementation.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.