# Tag Info

40

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 backwards in time requires you to predict the future, so it can't be used in "online" real-life applications, only for offline processing of recordings of signals. lfilter is causal forward-in-time ...

20

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 filter. This means that if the data is being filtered as it's gathered, this will not be an option (only valid for stored data which we can post-process). When ...

19

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)-0.5X(z)z^{-1}$ $H(z)=\dfrac{Y(z)}{X(z)}=\dfrac{1-0.5z^{-1}}{1-0.5z^{-1}}=1$ Yes, it can be tricky. Seeing $y[n-k]$ coefficients in LCCDE (Linear Constant ...

19

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$ is the transition band, in same units of $f_s$ $f_s$ is the sample rate of the filter $\rm atten_{dB}$ is the target rejection in dB For example if you have a ...

18

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: \begin{align}\text{IIR}& \Longrightarrow\text{recursive}\\ \text{non-recursive}&\Longrightarrow\text{FIR}\end{align} i.e. every IIR filter (i.e. ...

15

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 $$H(z)=\frac{\alpha}{1-(1-\alpha)z^{-1}}\tag{2}$$ The exact formula for the required value of $\alpha$ ...

11

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]$ going in, is $$y[n] = \operatorname{Quant}\{ v[n] \}$$ which we shall model as an additive error source: $$y[n] = v[n] + q[n]$$ No matter how the ...

11

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 example, take the exponential impulse response $$h[n]=a^nu[n],\qquad |a|<1\tag{1}$$ where $u[n]$ is the unit step function. The sum $$\sum_{n=-\infty}^{\... 10 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. Note that this is actually a leaky integrator, not a classic low pass filter, because its frequency response does not have a zero at Nyquist. The high pass ... 9 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 continuous-time integrator, but this doesn't mean that you will necessarily obtain an ideal integrator by transforming the discrete-time system to a continuous-time ... 9 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 a real-valued even function or a purely imaginary odd function, and \tau is some real-valued parameter (the delay). If A(\omega) is purely imaginary, then ... 9 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 management is done). Arithmetic operation translates into clock cycles of your processor. That depends a lot on the efficiency of your instruction set and how good yo ... 8 As you have already pointed out in your question, it is not possible (without using optimization methods) to compute an exact L2 solution for the frequency domain design problem of IIR filters due to the non-linear relationship between the filter coefficients and the error function. There is, however, a method which can come close and which transforms the ... 8 Actually it seems MATLAB implementation of the filter() function is pretty straight forward and not fast. For a fast implementation, have a look at FilterM by Jan Simon. Update In the latest releases of MATLAB (From R2016b and above) the performance of the filter() function has improved. The methods to accelerate those operations are usually based on: ... 8 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 @endolith argue about effective order of filter obtained by filtfilt: lfilter does apply given filter and in Fourier space this is like applying filter transfer ... 8 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 response has a large overshoot towards high frequencies. What you actually want is an IIR filter, with poles away from the origin of the complex z-plane. A simple ... 8 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 function (which you didn't ask for) is:$$ H(z) = \frac{1-a}{1 - az^{-1}} $$so here is your single pole, at z=a in the complex plane. This filter is also known as ... 8 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 cut-off frequency. Note that in the quoted answer I used the constant \alpha=1-b. From formula (3) in that answer we get for the coefficient b$$b = 2-\...

8

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 for fixed point as you isolate two 2nd order systems and in doing so will be easier to keep stable under variations due to the quantization involved. For more ...

8

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. This means that the resulting FIR filter approximates the magnitude and the phase characteristic of the original IIR filter. So with this approach the phase will ...

8

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 signal.filtfilt. Use signal.lfilter. filtfilt does the same thing as lfilter, except twice, in opposite directions, which changes a causal filter into a zero-phase filter. However, as the ...

8

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 domain using optimization methods. Note that the properties of the classic designs are very restricted: piecewise constant desired magnitude responses, minimum-...

7

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 problem is to look at the FIR filter's impulse response and use a time domain method (such as Prony's method) to approximate that impulse response by an IIR ...

7

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 somehow work, there are some limitations: Frequency-domain filtering is usually much more computationally demanding. It is not for real-time. The problem ...

7

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 an arbitrarily long time, or add up observations), they will get an output, and can through the magic of correlation get the impulse response.

7

The logical implications are the following: "non-recursive" $\Longrightarrow$ FIR IIR $\Longrightarrow$ "recursive" But the opposites are not necessarily true because a FIR system can be implemented recursively (transfer function poles can be cancelled by zeros). Of course, when referring to "recursive" or "non-recursive" we always talk ...

6

I only need the total group delay, not spectrum of group delay. Group delay is a spectrum, so this doesn't make sense. The group delay is the derivative of the phase response of the filter, so in Python it can be calculated as from scipy import signal from numpy import pi, diff, unwrap, angle w, h = signal.freqs(b, a) group_delay = -diff(unwrap(angle(h))...

6

FDLS requires a causal frequency response. Your prototype frequency response has zero phase everywhere, which is most definitely not causal. An IIR filter order of 50 is humongous. When FDLS has too many poles and zeroes available, it "tries" to cancel excess poles with excess zeroes. Unfortunately, due to numerical limitations, the cancellation is often ...

6

If the Z-transform of the feedforward section is divisible by the Z-transform of the feedback section, the filter is FIR. Consider your example: $y[n] = y[n-1] + x[n] - x[n-3]$. The Z-transform is $\mathrm Y(z)- z^{-1}\mathrm Y(z) = \mathrm X(z) - z^{-3}\mathrm X(z)$, and the Z-transform of the response is \$\mathrm H(z) = \mathrm Y(z)/\mathrm X(z) = (1 - z^...

6

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 equalization, simply because the design process is much simpler than for IIR filters. The reason for this is the fact that the design problem can be formulated in such ...

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