filtic | R Documentation |
Compute the initial conditions for a filter.
filtic(filt, ...)
## Default S3 method:
filtic(filt, a, y, x = 0, ...)
## S3 method for class 'Arma'
filtic(filt, y, x = 0, ...)
## S3 method for class 'Ma'
filtic(filt, y, x = 0, ...)
## S3 method for class 'Sos'
filtic(filt, y, x = 0, ...)
## S3 method for class 'Zpg'
filtic(filt, y, x = 0, ...)
filt |
For the default case, the moving-average coefficients of an ARMA
filter (normally called |
... |
additional arguments (ignored). |
a |
the autoregressive (recursive) coefficients of an ARMA filter. |
y |
output vector, with the most recent values first. |
x |
input vector, with the most recent values first. Default: 0 |
This function computes the same values that would be obtained from the
function filter
given past inputs x
and outputs y
.
The vectors x
and y
contain the most recent inputs and outputs
respectively, with the newest values first:
x = c(x(-1), x(-2), ... x(-nb)); nb = length(b)-1
y = c(y(-1), y(-2), ... y(-na)); na = length(a)-a
If length(x) < nb
then it is zero padded. If length(y) < na
then it is zero padded.
Initial conditions for filter specified by filt
, input vector
x
, and output vector y
, returned as a vector.
David Billinghurst, David.Billinghurst@riotinto.com.
Adapted and converted to R by Geert van Boxtel
G.J.M.vanBoxtel@gmail.com.
filter
, sosfilt
, filtfilt
,
filter_zi
## Simple low pass filter
b <- c(0.25, 0.25)
a <- c(1.0, -0.5)
ic <- filtic(b, a, 1, 1)
## Simple high pass filter
b <- c(0.25, -0.25)
a <- c(1.0, 0.5)
ic <- filtic(b, a, 0, 1)
## Example from Python scipy.signal.lfilter() documentation
t <- seq(-1, 1, length.out = 201)
x <- (sin(2 * pi * 0.75 * t * (1 - t) + 2.1)
+ 0.1 * sin(2 * pi * 1.25 * t + 1)
+ 0.18 * cos(2 * pi * 3.85 * t))
h <- butter(3, 0.05)
l <- max(length(h$b), length(h$a)) - 1
zi <- filtic(h, rep(1, l), rep(1, l))
z <- filter(h, x, zi * x[1])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.