DSPRelated.com
Blogs

Setting the 3-dB Cutoff Frequency of an Exponential Averager

Rick LyonsOctober 22, 20126 comments

This blog discusses two ways to determine an exponential averager's weighting factor so that the averager has a given 3-dB cutoff frequency. Here we assume the reader is familiar with exponential averaging lowpass filters, also called a "leaky integrators", to reduce noise fluctuations that contaminate constant-amplitude signal measurements. Exponential averagers are useful because they allow us to implement lowpass filtering at a low computational workload per output sample.

Figure 1 shows two, a two-multiply and a one-multiply [1,2], exponential averagers. Given the same value for the α weighting factor, the two averagers have identical performance.

WEIGHTING FACTOR APPROXIMATION FORMULA
Years ago I was introduced to the following expression for computing the α weighting factor to set an averager's 3-dB cutoff frequency to fc Hz:

where fs is the averager's input data sample rate in Hz [1]. The “app” subscript in Eq. (1) stands for approximation. I did some Matlab modeling of Eq. (1) and found it to be useful so long as fc was less than roughly 0.1fs. I hadn't thought much more about Eq. (1) after that, thinking that it was a little-known approximation formula. However, I recently received an E-mail from a signal processing engineer asking why I didn't include Eq. (1) in the 'Averaging' chapter of my DSP book. So perhaps Eq. (1) is more widely known than I thought. That E-mail convinced me that it might be useful to write a short blog on how to design an exponential averager with a given 3-dB cutoff frequency.

EXACT WEIGHTING FACTOR FORMULA
The correct expression for computing the α weighting factor to set an exponential averager's 3-dB cutoff frequency to fc Hz is [3]:

The “cor” subscript in Eq. (2) stands for correct. The derivation of the messy Eq. (2) is given in the Appendix.

So the question is, “What is the error in using the αapp approximate weighting factor for various values of the 3-dB cutoff frequency fc?” Figure 2 shows the frequency magnitude and phase responses of two exponential averagers when the fc cutoff frequency is one tenth of the fs sample rate. The solid blue curves correspond to a correct αcor computed using Eq. (2). The dashed red curves correspond to an αapp computed using Eq. (1).

The solid blue αcor magnitude curve in Figure 2 has the desired -3 dB value at fc = 0.1fs Hz. The dashed red αapp magnitude curve's value at fc Hz is -2.86 dB. So at such a low value of fc, the two magnitude curves are quite similar and Eq. (1) is an acceptable approximation to Eq. (2).

When we set fc = 0.2fs Hz, on the other hand, Eq. (1)'s αapp falls short on performance. Figure 3 shows the performance of the two exponential averagers when fc = 0.2fs Hz. The solid blue αcor magnitude curve in Figure 3 has the desired -3 dB value at fc = 0.2fs Hz. The dashed red αapp magnitude curve's value at fc Hz is -2.46 dB, an error of 0.54-dB (an 18% error). At this higher value of fc Eq. (1) is not an acceptable approximation to Eq. (2).

It turns out that the Eq. (1) approximation formula is only reasonably accurate at low values of fc. As the fc cutoff frequency is increased in value the greater is the error when using Eq. (1), as shown in Figure 3.

The bottom line of this blog is that the Eq. (1) expression gives reasonably accurate results when the fc cutoff frequency is less than 0.1fs. Equation (2) gives exactly correct results regardless of the fc value.

REFERENCES
[1] V. Vassilevsky, “Efficient Multi-tone Detection,” IEEE Signal
     Processing Magazine, “DSP Tips & Tricks” column, March 2007.
[2] R. Lyons, “Understanding Digital Signal Processing”, 3rd
     Edition, Prentice Hall Publishing, 2011, pp. 789-780.
[3] Pages 613-614 of Reference [2].



APPENDIX A – Deriving Equation (2)
Here's how to derive Eq. (2). The expression for the frequency magnitude response of an exponential averager is [3]:

where frequency ω is a normalized angle in the range of 0 ≤ ω ≤ π (corresponding to a continuous-time frequency range of 0 –to- fs/2 Hz).

So the question is, "What's the expression for α, in terms of ω, so that |Hexp(ω)| = 1/sqrt(2) = 0.707?" If we square Eq. (A-1) and set |Hexp(ω)|2 = 0.5, we end up with:

Equation (A-2) can be written as:

Using the quadratic equation we can solve Eq. (A-3) for α as:

where ω = 2Πfc/fs, and fc is the 3-dB cutoff frequency in Hz. Regarding the plus and minus signs before the square root, we choose to use the plus sign for Eq. (2). Choosing the negative sign in Eq. (A-4) places the exponential averager's z-domain pole outside the unit circle. This is a bad thing.


[ - ]
Comment by kazOctober 24, 2012
Thanks Rick,

I assume the difference equation of your filter is:
y(n) = alpha.x(n) + (1-alpha).y(n-1) corresponding to figure 1 a, two multipliers

and if rearranged becomes:
y(n) = alpha.(x(n) - y(n-1) + y(n-1) corresponding to figure 1 b, one multiplier

However, I am used to the equation as follows:

y(n) = (1-alpha).x(n) + alpha.y(n-1)
In effect similar but with alpha defined in opposite sense.

Kaz
[ - ]
Comment by kazOctober 24, 2012
apologies for typo.It should be:

and if rearranged becomes:
y(n) = alpha.(x(n) - y(n-1)) + y(n-1) corresponding to figure 1 b, one multiplier
[ - ]
Comment by Rick LyonsOctober 28, 2012
Hi kaz,
Vladimir Vassilevsky showed that Figure 1(b) single-mutiply averager to me years ago. It's pretty neat. Did you see my 'Multiplierless Exponential Avetrager' blog?

[-Rick-]
[ - ]
Comment by kazOctober 29, 2012
Thanks Rick

I looked at your blog of multiplier-less Averager and it does correlate with my comments.

In FPGAs we are used to avoid multipliers by any means including shift multiplication(for power 2 coefficient), addition for small integer coefficient, pre-adding for symmetry etc. So the method in your blog of multiplierless approach applies in general to any case and not just the expenential averager.
But surely it suits the case as it has single coefficient in effect.

My general concept of integrators is as follows:

case(1): a simple accumulator that keeps adding up its own output with some extra bits.
case(2) as above but add up fraction of output by truncatiing few LSBs
case(3) as above but have some control over cutoff point such the alpha examples above.

case 1 may be ok for getting the mean of bipolar stream. but could easily overflow and break otherwise.
case 2 is similar to case 3 but with x(n) coefficient = 1 and y(n-1) coefficient = 1/2^n (n = number of lsbs chopped off.

case 3: Changing the sense of alpha as explained in my first comment is equivalent since then alpha will be redefined as e^fc/fs rather than 1-e^fc/fs.

Regards

Kaz
[ - ]
Comment by Mike22November 7, 2012
Rick,

Just wandering through. It seems like equation #1 is missing a minus sign.
a = 1 - e ^ -(2*pi*fc/fs)

Cheers

Mike
[ - ]
Comment by Erik HofmanMay 21, 2015
Thank you very much Rick, this page helped me to solve the final piece of the puzzle in my quest to search for a cascading, single pass, second order EMA filter by introducing the number of cascading sections into the formula. Works like a charm!

To post reply to a comment, click on the 'reply' button attached to each comment. To post a new comment (not a reply to a comment) check out the 'Write a Comment' tab at the top of the comments.

Please login (on the right) if you already have an account on this platform.

Otherwise, please use this form to register (free) an join one of the largest online community for Electrical/Embedded/DSP/FPGA/ML engineers: