filtfilt | R Documentation |
Forward and reverse filter the signal.
filtfilt(filt, ...) ## Default S3 method: filtfilt(filt, a, x, ...) ## S3 method for class 'Arma' filtfilt(filt, x, ...) ## S3 method for class 'Ma' filtfilt(filt, x, ...) ## S3 method for class 'Sos' filtfilt(filt, x, ...) ## S3 method for class 'Zpg' filtfilt(filt, x, ...)
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,
specified as a vector. If |
x |
the input signal to be filtered. If |
Forward and reverse filtering the signal corrects for phase distortion introduced by a one-pass filter, though it does square the magnitude response in the process. That’s the theory at least. In practice the phase correction is not perfect, and magnitude response is distorted, particularly in the stop band.
Before filtering the input signal is extended with a reflected part of both ends of the signal. The length of this extension is 3 times the filter order. The Gustafsson [1] method is then used to specify the initial conditions used to further handle the edges of the signal.
The filtered signal, normally of the same length of the input signal
x
, returned as a vector or matrix.
Paul Kienzle, pkienzle@users.sf.net,
Francesco Potortì,
pot@gnu.org,
Luca Citi, lciti@essex.ac.uk.
Conversion to R and adapted by Geert van Boxtel
G.J.M.vanBoxtel@gmail.com.
[1] Gustafsson, F. (1996). Determining the initial states in forward-backward filtering. IEEE Transactions on Signal Processing, 44(4), 988 - 992.
filter
, filter_zi
, Arma
,
Sos
, Zpg
bf <- butter(3, 0.1) # 10 Hz low-pass filter t <- seq(0, 1, len = 100) # 1 second sample x <- sin(2* pi * t * 2.3) + 0.25 * rnorm(length(t)) # 2.3 Hz sinusoid+noise z <- filter(bf, x) # apply filter plot(t, x, type = "l") lines(t, z, col = "red") zz <- filtfilt(bf, x) lines(t, zz, col="blue") legend("bottomleft", legend = c("original", "filter", "filtfilt"), lty = 1, col = c("black", "red", "blue"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.