0
$\begingroup$

I am studying filters, in particular the Infinite Impulse Response ones.

I digged into theory and practice and I gain some decent knowledge on the topic. However, I can't really figure out or find good resurces about the so called "Initial conditions" or "State of the IIR".

So far I kind of understood that it is related to the fact that we are using a feedback on previous outputs (y(n)), but I couldn't find a clear and exhaustive explanation on the topic.

In the Digital Signal Processing, Proakis at page 91 of the book (107 if considering the PDF index) it says:

The term y(n_0 -1) is called the initial condition for the systems....

In Digital Signal Processing with Scipy at page 5, the author shows an example of a low pass IIR filter and shows how the initialization of the filter state changes the result of the output.

In the latter paper, the author uses 4 values as initial state, and I can't figure out why.

I'm having some problems in understanding the meaning of these initial conditions /state, where do they come from and how should I compute them. I know that Scipy and Matlab already provide functions to compute those states, but I would like to have a more deep knowledge and understanding of what's going on behind the "scenes".

$\endgroup$
7
  • 1
    $\begingroup$ Assuming linear time-invariant (LTI) filters, in the time-domain what you have is a linear constant coefficient difference equation (LCCDE), and in the frequency domain what you have is a Fourier transform of the associated time-domain solution of the LCCDE for an impulse input. So, to learn about filters you should first learn about LCCDE and their solutions; in particular how to obtain the impulse response. Initial conditions are required to solve LCCDEs. Note: for LTI system, the initial conditions are necessarily zero, yet nonzero if you have a block based filtering of long input data. $\endgroup$
    – Fat32
    Mar 10 at 12:58
  • $\begingroup$ Ooohh I see, this makes sense, I totally forgot about Differential Equations. Anyway, I am using scipy lfilter with a 2 order butterworth filter, and the lfilter function returns a state array with 4 values. How can I determine the "number" of states? $\endgroup$ Mar 10 at 15:24
  • $\begingroup$ Is it a SISO filter? If you look at the transfer function of the butterworth filter, what's the order of the denominator (or if it's state-space, how big is the A matrix)? Four initial conditions implies a 4th-order filter, or two independent 2nd-order filters running in parallel. $\endgroup$
    – TimWescott
    Mar 11 at 1:19
  • $\begingroup$ @TimWescott In my case it's a band-pass butterworth filter of second order. Im declaring it using the scipy.signal.butter function and it returns two set of coefficients (a,b), which are 5 values long each one. Once I get the filter i use scipy.signal.lfilter to filter a signal with the given parameters of the butterworth filter, and the function returns a state of 4 values. I couldn't figure out why it returns 4 values $\endgroup$ Mar 11 at 11:03
  • 1
    $\begingroup$ I was thinking it might be something like that. There is this quirk in the nomenclature for filters. You can derive a band pass filter from a low pass prototype. When you do this the actual number of states doubles. Strictly speaking, then, the order also doubles. But some authors will stick with the order of the prototype low pass filter. So your "second order" band pass filter is actually fourth order. And that is why it needs four initial conditions. $\endgroup$
    – TimWescott
    Mar 11 at 15:27
1
$\begingroup$

The states depend on the form of an IIR filter. Take second order filters for simplicity. The following picture shows the structure of a transposed direct form II filter.

Transposed-Direct-Form-II

The differential equation is

$y(n) = b_0 x(n) + s_1(n)$

and the filter states can be calculated by recurrence

$s_1(n) = b_1 x(n-1) + s_2(n-1) - a_1 y(n-1)$

$s_2(n) = b_2 x(n-1) - a_2 y(n-1)$

As for (transposed) direct form I, it should have a filter states with 4 elements. The following is the transposed direct form I implementation of a second order filter.

Transposed-Direct-Form-I

$\endgroup$
7
  • $\begingroup$ So the number of states actually depends on the implementation of the filter? From what I studied on my books, the same difference equation of an IIR filter can be represented both in direct 1 and 2 form (or transposed). However it seems that the number of states is "implementation" dependent. On the other hand, "mathematically" speaking, in some books/papers they refer to "state/initial condition" as the values of the filter at the "beginning" of the computation, so basically they check if the system is relaxed or has already processed some data, thus the feed back ( y(n-1) ecc...)is not 0. $\endgroup$ Mar 11 at 11:08
  • $\begingroup$ I am having an hard time to gather and organize my knowledge on the topic. I think I am kind of confusing the state that you showed in your answer with the state they (some papers/books) refer to when solving difference equation (basically the initial conditions needed to solve a difference/differential equation) $\endgroup$ Mar 11 at 11:09
  • $\begingroup$ The states I said are $s_1(n)$ to $s_4(n)$ in the signal flow diagrams. But I think they somehow represent the initial conditions of the differential equations to be solved. The equation $y(n) = b_0x(n) + b_1x(n-1)+b_2x(n-2)-a_1y(n-1)-a_2y(n-2)$ is mathematically right, but in practice you need something more explicit to calculate $y(n)$ instead of the feedbacks. You can try to implement IIR filters of direct form I and II, then you'll figure out the difference. $\endgroup$
    – ZR Han
    Mar 11 at 12:10
  • 1
    $\begingroup$ In Scilab, the number of initial states equals the number of states in the filter. This, in turn, is equal to the order of the denominator polynomial of the transfer function. Your denominator polynomial has five elements, which means that it is a fourth order polynomial. In turn, that means that it is a fourth order filter, no matter how it might be termed. $\endgroup$
    – TimWescott
    Mar 11 at 15:30
  • $\begingroup$ @TimWescott Why do you say my denominator polynomial has 5 elements? In my example, numerators are $b_0$ $b_1$ and $b_2$, and denominators are $a_0$(equals to 1) $a_1$ and $a_2$. BTW, for (transposed) direct form II which uses the minimum length of delay line, the number of filter states should equal to the maximum length of the numerator polynomial and the denominator polynomial. See more at here $\endgroup$
    – ZR Han
    Mar 12 at 1:14

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.