Moving average filters

Moving average filters compute the average of the last \(k\) inputs \(x[i]\), where k is the size of the window of the FIR filter:

\[y\left[n\right] = \frac{1}{k} \cdot \sum_{i=0}^{k-1} x[n-i]\]

These filters do not have an analog equivalent. They only exist as digital filters. Moving average filters are often used to filter short-term fluctuations from time series data. This type of filter has often the best response in the time domain, but the frequency domain will always contain ripples.

Lowpass filters

Computing the coefficients is really easy for a lowpass, as all coefficients are equal to \(\frac{1}{k}\). Here is are graphs of the filter response for a 16 value moving average low pass:

Filter response

Please enable javascript to see the graphs!
Drawing on a canvas is not supported by your browser!
Drawing on a canvas is not supported by your browser!
Drawing on a canvas is not supported by your browser!
Drawing on a canvas is not supported by your browser!

Code snippets

Here are snippets to create this filter:

Please enable javascript to see the generated code!

Highpass

A 16 value moving average high pass has the following response:

Filter response

Please enable javascript to see the graphs!
Drawing on a canvas is not supported by your browser!
Drawing on a canvas is not supported by your browser!
Drawing on a canvas is not supported by your browser!
Drawing on a canvas is not supported by your browser!

Code snippets

Here are snippets to create this filter:

Please enable javascript to see the generated code!