Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

filtic

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

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

gsignal

Signal Processing

v0.3-1
GPL-3
Authors
Geert van Boxtel [aut, cre] (Maintainer), Tom Short [aut] (Author of 'signal' package), Paul Kienzle [aut] (Majority of the original sources), Ben Abbott [ctb], Juan Aguado [ctb], Muthiah Annamalai [ctb], Leonardo Araujo [ctb], William Asquith [ctb], David Bateman [ctb], David Billinghurst [ctb], Juan Pablo Carbajal [ctb], André Carezia [ctb], Vincent Cautaerts [ctb], Eric Chassande-Mottin [ctb], Luca Citi [ctb], Dave Cogdell [ctb], Carlo de Falco [ctb], Carne Draug [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], R.G.H Eschauzier [ctb], Andrew Fitting [ctb], Alan J. Greenberger [ctb], Mike Gross [ctb], Daniel Gunyan [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Jake Janovetz [ctb], Alexander Klein [ctb], Peter V. Lanspeary [ctb], Bill Lash [ctb], Friedrich Leissh [ctb], Laurent S. Mazet [ctb], Mike Miller [ctb], Petr Mikulik [ctb], Paolo Neis [ctb], Georgios Ouzounis [ctb], Sylvain Pelissier [ctb], Francesco Potortì [ctb], Charles Praplan [ctb], Lukas F. Reichlin [ctb], Tony Richardson [ctb], Asbjorn Sabo [ctb], Thomas Sailer [ctb], Rolf Schirmacher [ctb], Rolf Schirmacher [ctb], Ivan Selesnick [ctb], Julius O. Smith III [ctb], Peter L. Soendergaard [ctb], Quentin Spencer [ctb], Doug Stewart [ctb], P. Sudeepam [ctb], Stefan van der Walt [ctb], Andreas Weber [ctb], P. Sudeepam [ctb], Andreas Weingessel [ctb]
Initial release
2021-05-02

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.