filter_zi(filt,...)## Default S3 method:filter_zi(filt, a,...)## S3 method for class 'Arma'filter_zi(filt,...)## S3 method for class 'Ma'filter_zi(filt,...)## S3 method for class 'Sos'filter_zi(filt,...)## S3 method for class 'Zpg'filter_zi(filt,...)
Arguments
filt: For the default case, the moving-average coefficients of an ARMA filter (normally called b), specified as a vector.
...: additional arguments (ignored).
a: the autoregressive (recursive) coefficients of an ARMA filter, specified as a vector.
Returns
The initial state for the filter, returned as a vector.
Details
This function computes an initial state for the filter function that corresponds to the steady state of the step response. In other words, it finds the initial condition for which the response to an input of all ones is a constant. Therefore, the results returned by this function can also be obtained using the function filtic by setting x and y to all 1s (see the examples).
A typical use of this function is to set the initial state so that the output of the filter starts at the same value as the first element of the signal to be filtered.
Examples
## taken from Python scipy.signal.lfilter_zi documentationh <- butter(5,0.25)zi <- filter_zi(h)y <- filter(h, rep(1,10), zi)## output is all 1, as expected.y2 <- filter(h, rep(1,10))## if the zi argument is not given, the output## does not return the final conditionsx <- c(0.5,0.5,0.5,0.0,0.0,0.0,0.0)y <- filter(h, x, zi = zi*x[1])## Note that the zi argument to filter was computed using## filter_zi and scaled by x[1]. Then the output y has no## transient until the input drops from 0.5 to 0.0.## obtain the same results with filticlab <- max(length(h$b), length(h$a))-1ic <- filtic(h, rep(1, lab), rep(1, lab))all.equal(zi, ic)
References
Gustafsson, F. (1996). Determining the initial states in forward-backward filtering. IEEE Transactions on Signal Processing, 44(4), 988 - 992.