filtfilt               package:signal               R Documentation

_F_o_r_w_a_r_d _a_n_d _r_e_v_e_r_s_e _f_i_l_t_e_r _a _s_i_g_n_a_l

_D_e_s_c_r_i_p_t_i_o_n:

     Using two passes, forward and reverse filter a signal.

_U_s_a_g_e:

     ## 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 'Zpg':
     filtfilt(filt, x, ...)

_A_r_g_u_m_e_n_t_s:

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

       a: the autoregressive (recursive) coefficients of an ARMA
          filter. 

       x: the input signal to be filtered. 

     ...: additional arguments (ignored). 

_D_e_t_a_i_l_s:

     This 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.

     In this version, we zero-pad the end of the signal to give the
     reverse filter time to ramp up to the level at the end of the
     signal. Unfortunately, the degree of padding required is dependent
     on the nature of the filter and not just its order, so this
     function needs some work yet.

     Since 'filtfilt' is generic, it can be extended to call other
     filter types.

_V_a_l_u_e:

     The filtered signal, normally the same length as the input signal
     'x'.

_A_u_t_h_o_r(_s):

     Original Octave version by Paul Kienzle, pkienzle@user.sf.net.
     Conversion to R by Tom Short.

_R_e_f_e_r_e_n_c_e_s:

     Octave Forge <URL: http://octave.sf.net>

_S_e_e _A_l_s_o:

     'filter', 'Arma', 'fftfilt'

_E_x_a_m_p_l_e_s:

     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
     y = filtfilt(bf,x)
     z = filter(bf, x) # apply filter
     plot(t,x)
     points(t,y,col="red")
     points(t,z,col="blue")
     legend("bottomleft", legend = c("data","filtfilt","filter"), pch = 1, col=c("black","red","blue"), bty="n")

