43 votes
Accepted

Applying filter in scipy.signal: Use lfilter or filtfilt?

filtfilt is zero-phase filtering, which doesn't shift the signal as it filters. Since the phase is zero at all frequencies, it is also linear-phase. Filtering ...
  • 15.1k
21 votes

What is the advantage of MATLAB's filtfilt

I found this video to be very, very helpful (it elaborates on Matt's answer). Here are some key ideas from the video: Zero-phase will result in no phase distortion, but will result in a non-causal ...
  • 357
19 votes
Accepted

What kind of filter is that? Is it IIR?

This is the FIR filter, although it looks like an IIR. If you calculate the coefficients you get finite impulse response: $h=[1]$ This happens due to zero-pole cancellation: $Y(z)-0.5Y(z)z^{-1}=X(z)...
  • 10.7k
19 votes
Accepted

Filter Order Rule of Thumb

My favorite "Rule of thumb" for the order of a low-pass FIR filter is the "fred harris rule of thumb": $$ N=\frac{f_s}{\Delta f}\cdot\frac{\rm atten_{dB}}{22} $$ where $\Delta f$ ...
  • 38.4k
18 votes

What kind of filter is that? Is it IIR?

Jojek's answer is of course correct. I would just like to add some more information because much too often have I seen the terms "IIR" and "recursive" confused. The following implications always hold: ...
  • 80.9k
16 votes
Accepted

Single-pole IIR low-pass filter - which is the correct formula for the decay coefficient?

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 ...
  • 80.9k
13 votes
Accepted

Are all IIR filters unstable in nature?

Note that for stable IIR filters, the impulse response does approach zero as $n$ goes to infinity. It just never becomes exactly zero. However, the sum of the absolute values is finite. Just as an ...
  • 80.9k
13 votes
Accepted

FFT-based fast convolution vs IIR filtering

For a simple 10-band equalizer, it would be very hard to beat the IIR implementation. For most HW architectures the break-even point between direct FIR convolution and Overlap Add/Save (OLA) is ...
  • 34k
12 votes

What is the maximum output of an IIR filter?

I would like to know,if there is any way to estitmate what could be the maximum limits of the output Yes. It's $$y_{max} = x_{max} \cdot \sum_{n = 0}^{\infty} |h[n]| $$ I.e. the maximum gain is the ...
  • 34k
11 votes

best implementation of a real-time, fixed-point iir filter with constant coefficients

what is fraction saving? can you write a code.so that i can understand more clearly? Let's call the quantizer operator $\operatorname{Quant}\{\cdot\}$ . So the output of the quantizer, with $v[n]$ ...
10 votes

Applying filter in scipy.signal: Use lfilter or filtfilt?

Answer by @endolith is complete and correct! Please read his post first, and then this one in addition to it. Due to my low reputation I was unable to respond to comments where @Thomas Arildsen and @...
  • 201
10 votes
Accepted

How to produce a high-pass filter from a low-pass one?

The result will indeed be a high pass filter. From your difference equation, the transfer function of the low pass filter is $$H_l(z)=\frac{\beta}{1-(1-\beta)z^{-1}}\tag{1}$$ with $\beta=1/\alpha$. ...
  • 80.9k
9 votes
Accepted

Is $y[k] = y[k-1] + x[k]$ an integrator?

The system $$y[n]=y[n-1]+x[n]\tag{1}$$ is an ideal accumulator, i.e., it computes the cumulative sum of the input samples: $$y[n]=\sum_{k=-\infty}^nx[k]\tag{2}$$ It is in a way analogous to a ...
  • 80.9k
9 votes
Accepted

Why can't realisable IIR filters have linear phase?

The frequency response of a real-valued discrete-time system with linear phase has the form $$H(e^{j\omega})=A(\omega)e^{-j\omega\tau},\qquad\omega\in [-\pi,\pi]\tag{1}$$ where $A(\omega)$ is either ...
  • 80.9k
9 votes
Accepted

How do software equalizers work?

This depends a lot on how you implement it. A single biquad takes about 10 arithmetic operations. (To be precise a Transposed Form II takes 4-5 multiplies and 3 adds, depending on how the gain ...
  • 34k
8 votes
Accepted

Analytically designing a notch-filter for specified frequency 50 Hz

You've designed a causal filter with a notch at $\omega_0=100\pi$. But the result is probably not what you want. Note that you've designed an FIR (finite impulse response) filter. Its frequency ...
  • 80.9k
8 votes
Accepted

How does this "simple filter" work?

In more standard DSP terms, you have the following filter: $$ y[n] = (1-a) x[n] + a y[n-1] $$ where $x[n]$ and $y[n]$ are the input and output signals at time $n$ respectively. The transfer ...
  • 4,751
8 votes
Accepted

Cutoff frequency of a first order recursive filter

That formula for the cut-off frequency is a very inaccurate approximation. In this answer I derived the exact relation between the coefficient of a first order recursive averaging filter and its 3-dB ...
  • 80.9k
8 votes
Accepted

4th order high-pass filter on a DSP: standard or biquads?

The two solutions in a floating point implementation are assumed to be identical, with the two BiQuads being a factored version of the standard difference equation. The BiQuad is the better way to go ...
  • 38.4k
8 votes
Accepted

Design a linear-phase FIR filter approximating the magnitude of a given IIR filter

What you do in step 1 is simply truncate the infinite impulse response to approximate it by an FIR filter. If you use sufficiently many filter taps, the approximation becomes arbitrarily accurate. ...
  • 80.9k
8 votes
Accepted

Meaning of Phase response of a filter? In simple words?

There are many good answers here. I will try to take the reverse approach in order to explain in very simple words what is necessary in order to keep the output's shape same as input's, and what ...
  • 2,496
8 votes
Accepted

Are IIR filters (and specifically Butterworth filter) causal?

Yes, Butterworth are IIR. The decay from an impulse technically lasts forever. Yes, all [implementable] IIR are causal. Yes, because of #1 and #2. Don't use ...
  • 15.1k
8 votes

Mapping of Classic Filters for Digital Filter Design

I'm convinced that depending on the problem we're trying to solve, we can and should use both approaches: the transformation of classic analog filter designs, and the direct design in the digital ...
  • 80.9k
7 votes
Accepted

How to design a filter with custom group delay -- why is it an IIR?

As pointed out by Peter K., it is true that many well-known techniques for designing FIR filters actually only design linear phase filters. However, FIR filters are very well suited for delay ...
  • 80.9k
7 votes
Accepted

Convert a FIR to an equivalent IIR

I would say that the answer to your question - if taken literally - is 'no', there is no general way to simply convert an FIR filter to an IIR filter. I agree with RBJ that one way to approach the ...
  • 80.9k
7 votes

What's the advantage of adaptive IIR filter against FIR?

These are the key differences between FIR and IIR filters, regarding the feature you wish to control are the following: $$ \begin{array}{c|lcr} \text{Feature} & \text{IIR} & \text{FIR} \\ \...
  • 1,367
7 votes

Frequency Domain Filtering

This is just "faking" the magnitude response of an IIR filter. The output's magnitude spectrum looks just like it has been filtered by the IIR filter with the given frequency response. Although it may ...
  • 4,115
7 votes
Accepted

Protect an IIR filter from being reverse-engineered

Short answer: You can't. If an attacker can insert a signal that covers the whole bandwidth (e.g. a white signal, or at least one that has no spectral zeros) into the system (and he can do that over ...
7 votes

Single pole IIR filter, fixed point design

One thing to consider when implementing an IIR filter, whatever the order, is quantization and limit cycles. Let me show you with a quick example with your original filter $y[n] = a*x[n]+(1-a)*y[n-1]...
  • 3,670
7 votes
Accepted

3 dB cut-off frequency of first-order IIR high-pass filter

A discrete-time first-order high pass filter with unity gain at Nyquist and a zero at DC is described by the following difference equation: $$y[n]=\frac{1+\alpha}{2}\big(x[n]-x[n-1]\big)+\alpha y[n-1],...
  • 80.9k

Only top scored, non community-wiki answers of a minimum length are eligible