A single-pole IIR low-pass filter can be defined in discrete time as y += a * (x - y), where y is the output sample, x is the input sample and a is the decay coefficient.

However, the definition of a varies. On Wikipedia, it's defined as 2πfc/(2πfc+1) (where fc is the cutoff frequency).

But here, a is defined as follows: 1 - e^-2πfc.

Their graphs look similar, but which one is more accurate?

The blue graph is the Wikipedia formula, the green is the second one, fc is the x-axis. GeoGebra graph

  • $\begingroup$ Possible duplicate of Exponential weighted moving average time constant $\endgroup$ – Matt L. Dec 12 '18 at 9:04
  • $\begingroup$ I disagree. There are two conflicting formulas given, but the question you linked covers how one of them can be derived. Edit: However, there's a note that the formulas are only an approximation, which might imply that both of those are usable. $\endgroup$ – Mark Dec 12 '18 at 9:07
  • 1
    $\begingroup$ See my answer below, both are indeed approximations derived from the corresponding analog filter, and only one of them is useful, provided that the cut-off frequency is much smaller than Nyquist. $\endgroup$ – Matt L. Dec 12 '18 at 12:17

The given single-pole IIR filter is also called exponentially weighted moving average (EWMA) filter, and it is defined by the following difference equation:

$$y[n]=\alpha x[n]+(1-\alpha)y[n-1],\qquad 0<\alpha<1\tag{1}$$

Its transfer function is


The exact formula for the required value of $\alpha$ that results in a desired $3\;\textrm{dB}$ cut-off frequency $\omega_c$ was derived in this answer:

$$\alpha=-y+\sqrt{y^2+2y},\qquad y=1-\cos(\omega_c)\tag{3}$$

Even though it should be easy enough to compute $\alpha$ from $(3)$, there are several approximative formulas floating around the internet. One of them is

$$\alpha\approx 1-e^{-\omega_c}\tag{4}$$

In this answer I've explained how this formula is derived (namely, via the impulse invariant transformation of the corresponding continuous-time low pass filter). This answer compares the approximation $(4)$ with the exact formula, and it is shown that $(4)$ is only useful for relatively small cut-off frequencies (of course, small compared to the sampling frequency).

In the wikipedia link given in the question, there is yet another approximative formula:


[Note that in all formulas of this answer $\omega_c$ is normalized by the sampling frequency.] This approximation is also derived from discretizing the corresponding analog transfer function, this time not via the impulse invariant method, but by replacing the derivative by a backward difference:

$$\frac{dy(t)}{dt}{\huge |}_{t=nT}\approx\frac{y(nT)-y((n-1)T)}{T}\tag{6}$$

This is equivalent to replacing $s$ by $(1-z^{-1})/T$ in the continuous-time transfer function


which results in


Comparing $(8)$ to $(2)$ we see that


Since the (continuous-time) $3\;\textrm{dB}$ cut-off frequency is $\Omega_c=1/\tau$, we obtain from $(9)$


Equating the discrete-time cut-off frequency $\omega_c$ with $\Omega_cT$ in $(10)$ gives the approximation $(5)$.

The figure below shows the actually achieved cut-off frequency for a given desired cut-off frequency for the two approximations $(4)$ and $(5)$. Clearly, both approximations become useless for larger cut-off frequencies, and I would suggest that approximation $(5)$ is generally useless.

enter image description here

  • $\begingroup$ How about this approximation (sorry, just in coefficient format ): x = 1.0/(fs*T); % fs in Hz, T in μs a0 = 1.0; a1 = -(1 + x + 0.5 * x^2); % Taylor approx b0 = a0 + a1; % gain b1 = 0.0; $\endgroup$ – Juha P Mar 26 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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