medianFilter             package:fractal             R Documentation

_M_e_d_i_a_n _f_i_l_t_e_r_i_n_g _o_f _a _t_i_m_e _s_e_r_i_e_s

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

     Given a filter order P, the output of applying a median filter to
     a time series X[t] for t=0, ..., N - 1 is

     _P _o_d_d: Y[ k ]=median(X[ k - (P - 1) / 2, ...,   k + (P - 1) / 2 ])

     _P _e_v_e_n: Y[ k ]=median(X[ k - P / 2, ...,   k + P / 2 - 1 ]) .in -5

          for k=0, ..., N - 1. Thus, median filtering replaces the kth
          value of the time series with the median of the time series
          over an P-point window centered about point k. In the case
          where a portion of the window exceeds the boundaries of the
          time series, the values outside the boundaries are ignored in
          the median value calculation.

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

     medianFilter(x, order=2)

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

       x: a vector containing a uniformly-sampled real-valued time
          series.

   order: the median filter order. This argument defines the size of
          the windows over which the median values are calculated. The
          filter order must be positive and less than twice the length
          of the time series. Default: '2'.

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

     a vector containing the result and of the same length as the
     original time series.

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

     'localProjection'.

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

     x      <- beamchaos@data
     x      <- x - mean(x)
     sigma  <- stdev(x)
     xnoise <- x + rnorm(length(x)) * sigma / 3
     xclean <- medianFilter(xnoise, order=10)
     y <- data.frame(xclean, xnoise, x)

     stackPlot(x=positions(beamchaos)[], y=y,
         ylab=c("denoised","noisy","original"),
         ylim=range(y))

