Construct initial conditions for lfilter
Given a linear filter (b,a) and initial conditions on the output y and the input x, return the inital conditions on the state vector zi which is used by lfilter to generate the output given the input.
If M=len(b)-1 and N=len(a)-1. Then, the initial conditions are given in the vectors x and y as:
x = {x[-1],x[-2],...,x[-M]}
y = {y[-1],y[-2],...,y[-N]}
If x is not given, its inital conditions are assumed zero. If either vector is too short, then zeros are added to achieve the proper length.
The output vector zi contains:
zi = {z_0[-1], z_1[-1], ..., z_K-1[-1]} where K=max(M,N).