Wave Walker DSP

DSP Algorithms for RF Systems

Buy the Book!

Foundations of Digital Signal Processing: Complex Numbers is available Amazon now! Great for young engineers looking for a simple explanation of complex numbers.

Bandwidth of a Moving Average Filter
August 3, 2022

Table of Contents

Introduction

This blog shows how to approximate the 3 dB cutoff frequency of the moving average filter.

Check out these other blogs!

Moving Average Filter Impulse Response

The boxcar filter or boxcar window is an FIR filter whose weights are all 1:

(1)   \begin{equation*}h_{box}[n] = \begin{cases}1, & 0 \le n \le N-1 \\0, & \text{otherwise}.\end{cases}\end{equation*}

The filter weights in (1) are normalized in the time domain to create a moving average (MA) filter

(2)   \begin{equation*}h_{ma}[n] = \begin{cases}1/N, & 0 \le n \le N-1 \\0, & \text{otherwise}.\end{cases}\end{equation*}

Magnitude-Squared Frequency Response

The magnitude-squared of the frequency response for the boxcar window was derived in a previous blog,

(3)   \begin{equation*}\left| H_{box}\left( e^{j\omega} \right) \right|^2 = \frac{1 - \cos \left( \omega N \right)}{1 - \cos \left( \omega \right)}.\end{equation*}

The moving average is normalized by a factor of 1/N therefore the magnitude-squared of the moving average is normalized by a factor of 1/N^2,

(4)   \begin{equation*}\begin{split}\left| H_{ma}\left( e^{j\omega} \right) \right|^2 & = \frac{1}{N^2} \left| H_{box}\left( e^{j\omega} \right) \right|^2 \\& =\frac{1 - \cos \left( \omega N \right)}{N^2\left(1 - \cos \left( \omega \right)\right)}\end{split}\end{equation*}

Gain at Zero-Frequency (omega=0)

There are multiple bandwidth definitions (see Bandwidth Measures). The focus of this blog is the half-power or 3 dB measure. The 3 dB bandwidth in decibels is

(5)   \begin{equation*}10\text{log}_{10}\left( 1/2 \right) \approx - 3~\text{dB}.\end{equation*}

The moving average filter is a low-pass filter whose magnitude is the maximum value at \omega = 0. Therefore to measure the half-energy point the maximum value has to be calculated, which is (4) at \omega = 0,

(6)   \begin{equation*}\begin{split}\left| H_{ma}\left( e^{j\omega} \right) \right|^2 |_{\omega=0} & = \frac{1 - \cos \left( 0 \right)}{N^2\left(1 - \cos \left( 0 \right)\right)} \\& = \frac{1}{N^2}. \\\end{split}\end{equation*}

Finding the 3 dB Bandwidth

The 3 dB bandwidth is the frequency \omega at which the magnitude-squared is 1/2 the maximum value,

(7)   \begin{equation*}\frac{1}{2} \left| H_{ma}\left( e^{j\omega} \right) \right|^2 |_{\omega=0} = \frac{1}{2N^2}.\end{equation*}

After substituting (4) equation (7) can now be written as

(8)   \begin{equation*}\frac{1}{2N^2} = \frac{1 - \cos \left( \omega N \right)}{N^2\left(1 - \cos \left( \omega \right)\right)}\end{equation*}

which is simplified to

(9)   \begin{equation*}\frac{1}{2} = \frac{1 - \cos \left( \omega N \right)}{1 - \cos \left( \omega \right)}.\end{equation*}

Finding a closed-form solution for (9) is not trivial (see Wolfram’s solution when N=5), but the bandwidth can be approximated as approximately

(10)   \begin{equation*}\omega_{3dB} = \pi/N.\end{equation*}

Figures 1-3 show the cutoff frequency approximation (10) for N=5, 10 and 16.

Figure 1: The cutoff frequency approximation for a moving average filter of length 5.
Figure 1: The cutoff frequency approximation for a moving average filter of length 5.
Figure 2: The cutoff frequency approximation for a moving average filter of length 10.
Figure 2: The cutoff frequency approximation for a moving average filter of length 10.
Figure 3: The cutoff frequency approximation for a moving average filter of length 16.
Figure 3: The cutoff frequency approximation for a moving average filter of length 16.

The cutoff approximation (10) is not an exact value for the frequency but it is a reasonable approximation. 

Conclusion

The moving average filter is a normalized boxcar window or boxcar filter. The 3 dB point is where the magnitude-squared is 0.5. The 3 dB bandwidth of a moving average filter length N can be approximated by \omega = \pi/N.

Check out these other blogs!

Leave a Reply