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

sgolay

Savitzky-Golay smoothing filters


Description

Computes the filter coefficients for all Savitzky-Golay smoothing filters.

Usage

sgolay(p, n, m = 0, ts = 1)

Arguments

p

filter order.

n

filter length (must be odd).

m

return the m-th derivative of the filter coefficients.

ts

time scaling factor.

Details

The early rows of the result F smooth based on future values and later rows smooth based on past values, with the middle row using half future and half past. In particular, you can use row i to estimate x[k] based on the i-1 preceding values and the n-i following values of x values as y[k] = F[i,] * x[(k-i+1):(k+n-i)].

Normally, you would apply the first (n-1)/2 rows to the first k points of the vector, the last k rows to the last k points of the vector and middle row to the remainder, but for example if you were running on a realtime system where you wanted to smooth based on the all the data collected up to the current time, with a lag of five samples, you could apply just the filter on row n-5 to your window of length n each time you added a new sample.

Value

An square matrix with dimensions length(n) that is of class 'sgolayFilter' (so it can be used with filter).

Author(s)

Original Octave version by Paul Kienzle pkienzle@users.sf.net. Modified by Pascal Dupuis. Conversion to R by Tom Short.

References

William H. Press, Saul A. Teukolsky, William T. Vetterling, Brian P. Flannery, Numerical Recipes in C: The Art of Scientific Computing , 2nd edition, Cambridge Univ. Press, N.Y., 1992.

Octave Forge http://octave.sf.net

See Also


signal

Signal Processing

v0.7-6
GPL-2
Authors
Uwe Ligges [aut, cre] (new maintainer), Tom Short [aut] (port to R), Paul Kienzle [aut] (majority of the original sources), Sarah Schnackenberg [ctb] (various test cases and bug fixes), David Billinghurst [ctb], Hans-Werner Borchers [ctb], Andre Carezia [ctb], Pascal Dupuis [ctb], John W. Eaton [ctb], E. Farhi [ctb], Kai Habel [ctb], Kurt Hornik [ctb], Sebastian Krey [ctb], Bill Lash [ctb], Friedrich Leisch [ctb], Olaf Mersmann [ctb], Paulo Neis [ctb], Jaakko Ruohio [ctb], Julius O. Smith III [ctb], Doug Stewart [ctb], Andreas Weingessel [ctb]
Initial release
2015-07-29

We don't support your browser anymore

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