Calculating pre-history of recursive filter from state space representation when optimising for initial z

For a recursive filter, suppose a set of $$b$$ and $$a$$ coefficients have been calculated. Assume a state-space representation for which an initial set of $$z$$-values have also been calculated as in Python's lfilter_zi function.

The author of this post demonstrates code that applies the filter using the state-space model.

We know that an equivalent filter representation is the recursive one

$$y[n] = \sum_{i=1}^{N} a[i]y[n-i] + \sum_{i=0}^{N} b[i]x[n-i]$$

My question is as follows: what are the pre-history values of $$x$$ and $$y$$ that, when used to cold-start the filter using the recursive formula, yield the same results as the application of the state-space model?

For example, for a 2nd order filter, I want to plug in the values of $$x[-2]$$, $$x[-1]$$, $$y[-2]$$ and $$y[-1]$$ in the recursive formula above for n=0 and n=1 and obtain the same results as when using the optimal $$z$$-values from the state-space model.

• you can find those intial values of $y[-1]$, $y[-2]$, by running the filter backwards... But beware that filter initial conditions can refer to intermediate states and not necessarily output values. May 24 '19 at 19:47