medianFilter

0th

Percentile

Median filtering of a time series

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

P odd:

\(Y[ k ]=\mbox{median}(X[ k - (P - 1) / 2, ..., k + (P - 1) / 2 ])\)

P even:

\(Y[ k ]=\mbox{median}(X[ k - P / 2, ..., k + P / 2 - 1 ])\)

for \(k=0, \ldots, N - 1\). Thus, median filtering replaces the \(k^{\mbox{th}}\) 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.

Keywords
models, nonlinear, univar
Usage
medianFilter(x, order=2)
Arguments
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.

Value

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

See Also

localProjection.

Aliases
  • medianFilter
Examples
# NOT RUN {
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))
# }
Documentation reproduced from package fractal, version 2.0-4, License: GPL-2

Community examples

Looks like there are no examples yet.