# Wave Walker DSP

## Trending

DSP for Beginners: Simple Explanations for Complex Numbers! The second edition includes a new chapter on complex sinusoids.

Bandwidth of a Moving Average Filter
August 3, 2022

#### 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)

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

(2)

#### Magnitude-Squared Frequency Response

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

(3)

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 ,

(4)

#### 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)

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

(6)

#### Finding the 3 dB Bandwidth

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

(7)

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

(8)

which is simplified to

(9)

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)

Figures 1-3 show the cutoff frequency approximation (10) for N=5, 10 and 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 .

Check out these other blogs!

### 3 Responses

1. Curt says:

This estimation approach can be used to determine the cutoff for a MA (lowpass) filter. What if I wanted to construct a MA bandpass filter from two lowpass filters? For example, if the filter length N based on the peak in the spectrum is 120 days, the low passband cutoff would be 38 days (3.14159/120=.02617, 1/.02617=38). Is there a way I cann use this estimation approach to determine the cutoff for the high passband of the MA bandpass filter?

2. > What if I wanted to construct a MA bandpass filter from two lowpass filters?

Are you required to use a moving average filter? It sounds like you are trying to build up a more sophisticated filter using the moving average as the foundation. I would be hesitant to do this, and I would design a band-pass filter using remez instead (see below).

The MA filter is a specific filter implementation where all of the taps are the same such that it computes the arithmetic mean of the input signal. It’s useful in some contexts but it doesn’t give you much control over the frequency response other than selecting the length N.

From what I can read into your question, it sounds like you need a band-pass filter in which you can specify the lower and upper cutoff frequency independently. If that’s the case I would design a band-pass filter with remez and skip the moving average filter. I have a blog here in which I describe how to do all of this using SciPy’s Remez function: https://www.wavewalkerdsp.com/2021/09/24/designing-fir-band-pass-filters-with-remez/

I hope this helps!

1. Curt A. Mitchell says:

Great. I’ll take a look. Thanks.

For everything there is a season, and a time for every matter under heaven. A time to cast away stones, and a time to gather stones together. A time to embrace, and a time to refrain from embracing. Ecclesiastes 3:1,5
The earth was without form and void, and darkness was over the face of the deep. And the Spirit of God was hovering over the face of the waters. Genesis 1:2
Behold, I am toward God as you are; I too was pinched off from a piece of clay. Job 33:6
Enter His gates with thanksgiving, and His courts with praise! Give thanks to Him; bless His name! Psalm 100:4
Lift up your hands to the holy place and bless the Lord! Psalm 134:2
Blessed is the man who trusts in the Lord, whose trust is the Lord. He is like a tree planted by water, that sends out its roots by the stream, and does not fear when heat comes, for its leaves remain green, and is not anxious in the year of drought, for it does not cease to bear fruit. Jeremiah 17:7-8
He said to him, “You shall love the Lord your God with all your heart and with all your soul and with all your mind. This is the great and first commandment. And a second is like it: You shall love your neighbor as yourself. On these two commandments depend all the Law and the Prophets.” Matthew 22:37-39
Then He said to me, “Prophesy over these bones, and say to them, O dry bones, hear the word of the Lord. Thus says the Lord God to these bones: Behold, I will cause breath to enter you, and you shall live." Ezekiel 37:4-5
Riches do not profit in the day of wrath, but righteousness delivers from death. Proverbs 11:4
The angel of the Lord appeared to him in a flame of fire out of the midst of a bush. He looked, and behold, the bush was burning, yet it was not consumed. And Moses said, “I will turn aside to see this great sight, why the bush is not burned.” When the Lord saw that he turned aside to see, God called to him out of the bush, “Moses, Moses!” And he said, “Here I am.” Exodus 3:2-3
Daniel answered and said: “Blessed be the name of God forever and ever, to whom belong wisdom and might. He changes times and seasons; He removes kings and sets up kings; He gives wisdom to the wise and knowledge to those who have understanding." Daniel 2:20-21
Now the Lord is the Spirit, and where the Spirit of the Lord is, there is freedom. 2 Corinthians 3:17

This website participates in the Amazon Associates program. As an Amazon Associate I earn from qualifying purchases.