12
$\begingroup$

I am trying to answer the following question:

Is the system described by equation:

$$y[n]=0.5y[n-1]+x[n]-0.5x[n-1]$$

an IIR filter? My answer is yes.

Thank you

$\endgroup$
6
  • 1
    $\begingroup$ there is a class of FIR filters called "Truncated IIR" (TIIR) filters. you can google that and you will find stuff from Julius Smith and Avery Wang. another example of TIIR filters is the Moving Sum or Moving Average filter or CIC filter (all pretty much different names for the same thing). what makes this recursive filter an FIR is pole-zero cancellation. as implemented, there are internal poles and if they were unstable, the filter could blow up inside, but you wouldn't see it in the output until there numerical limits were exceeded. $\endgroup$ Commented Feb 19, 2015 at 22:12
  • 1
    $\begingroup$ what are the numerical limits? $\endgroup$ Commented Feb 20, 2015 at 11:12
  • $\begingroup$ depends on the numerical type (float or fixed) and the word width. this stuff can be looked up. (say, for IEEE-754 floats. for fixed, it depends on how many bits, $n_I$, are left of the binary point; roughly $\pm 2^{n_I - 1}$. $\endgroup$ Commented Feb 20, 2015 at 17:20
  • $\begingroup$ thank you again sirs for all help! it helps a lot I am glad I found this web site $\endgroup$ Commented Feb 22, 2015 at 17:49
  • 2
    $\begingroup$ @AnthonyParks: You say: "why are people making this complicated..this is is clearly an IIR because first term of the filter has a feedback portion."? I say: "why people don't bother to understand the basic concepts of DSP"? IIR filter always implies the recursive form, but FIR doesn't necessary mean that the filter is non-recursive. That is the only correct answer and you are confusing the concepts here. If that was the exam question, you would fail by saying it is an IIR. Oppenheim explains this topic in his book on DSP. $\endgroup$
    – jojeck
    Commented May 30, 2015 at 21:57

2 Answers 2

19
$\begingroup$

This is the FIR filter, although it looks like an IIR. If you calculate the coefficients you get finite impulse response:

$h[n]=\delta[n]$

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 Coefficients Difference Equation) doesn't necessarily mean it's an IIR filter. It might be just a recursive FIR filter.

$\endgroup$
5
  • $\begingroup$ Still, if you implement the equations as originally stated, it will not behave exactly as H(z) = 1 because of finite word length effects (despite the pole-zero cancellation being exact in this case). $\endgroup$
    – Oscar
    Commented Feb 19, 2015 at 9:23
  • $\begingroup$ That is true @Oscar, but these are numerical issues which have nothing to do with filter being F/IIR. $\endgroup$
    – jojeck
    Commented Feb 19, 2015 at 9:27
  • 1
    $\begingroup$ @jojek: you are of course completely correct. However, using recursive FIR filters cause quite a bit of problems if you are unaware of these things (which many, even "high-quality" researchers, are). Hence, my comment. Ideally there should be a discussion of algorithm vs transfer function as well. $\endgroup$
    – Oscar
    Commented Feb 19, 2015 at 9:31
  • $\begingroup$ jojek i am reading your answer from this question you answerd but i cannot comment. dsp.stackexchange.com/questions/17605/… can i use diffrent window? $\endgroup$ Commented Feb 20, 2015 at 11:18
  • $\begingroup$ @BlackYasmin: Yes you can, just keep in mind you should call pwelch with appropriate window. $\endgroup$
    – jojeck
    Commented Feb 20, 2015 at 11:50
18
$\begingroup$

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. a discrete-time filter having an infinitely long impulse response) must be implemented recursively (unless you have infinite memory available), and every non-recursive LTI system has a finite impulse response (again, unless you have infinite memory).

However, the reverse is generally not true. A recursive filter can have a finite impulse response, as is the case for the example in the question. Another famous example is a moving average filter. This a non-recursive implementation of a moving average (necessarily FIR):

$$y[n]=\frac{1}{N}\sum_{k=n-N+1}^nx[k]$$

And this is a recursive implementation of the same filter (also FIR): $$y[n]=y[n-1]+\frac{1}{N}(x[n]-x[n-N])$$

$\endgroup$
9
  • 2
    $\begingroup$ Concise and accurate as always, +1 ;) Thank you for bringing up the MA case. $\endgroup$
    – jojeck
    Commented Feb 18, 2015 at 22:48
  • 1
    $\begingroup$ @jojek: yeah, I think it's a classic that everybody should know. $\endgroup$
    – Matt L.
    Commented Feb 18, 2015 at 22:49
  • $\begingroup$ And while I was primarily thinking of round-off noise in the comment to jojek's answer, for MA, overflow will be a potential issue which needs to be carefully considered. Easily solved by two's complement arithmetic and enough word length though. $\endgroup$
    – Oscar
    Commented Feb 19, 2015 at 9:26
  • 1
    $\begingroup$ @Oscar: Well, after doing very simple analysis with double floating point precision I got an error of 8.881784197001252e-16. This is after processing the equivalent of 1 year of audio at sampling frequency 44.1kHz. Input data is a Gaussian noise with normalized distribution. Here is the code to reproduce the result !click! (it might take a 3 days to run). Providing this is correct, then I believe there is nothing to worry about. $\endgroup$
    – jojeck
    Commented Mar 2, 2015 at 9:25
  • 1
    $\begingroup$ @jojek: Three things. 1) I was referring to the moving average filter of the answer, not the one in the original question. 2) Yes, that is OK for audio (but not exact, so no reason to put "no" in bold), but I prefer my safety critical signal processing to work independent of the input signal having synthetic properties. 3) The interesting thing is that the filter you simulated with will not have the problems I described (as the pole is inside the unit circle, not on it), but will always have round-off errors independent of representation (which can be avoided in the moving average case). $\endgroup$
    – Oscar
    Commented Mar 3, 2015 at 10:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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