filtic {gsignal}R Documentation

Filter Initial Conditions

Description

Compute the initial conditions for a filter.

Usage

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, ...)

Arguments

filt

For the default case, the moving-average coefficients of an ARMA filter (normally called b), specified as a vector. Generically, filt specifies an arbitrary filter operation.

...

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

Details

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.

Value

Initial conditions for filter specified by filt, input vector x, and output vector y, returned as a vector.

Author(s)

David Billinghurst, David.Billinghurst@riotinto.com.
Adapted and converted to R by Geert van Boxtel G.J.M.vanBoxtel@gmail.com.

See Also

filter, sosfilt, filtfilt, filter_zi

Examples

## 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])


[Package gsignal version 0.3-5 Index]