TOPICS
Search

Savitzky-Golay Filter


A Savitzky-Golay filter smooths data by fitting a polynomial in a moving window using polynomial least squares fitting and evaluating the fitted polynomial at the desired location (Savitzky and Golay 1964). A fit of polynomial degree d requires at least d+1 distinct data points. For equally spaced data, a fixed window and fixed polynomial degree give reusable convolution weights. Low-degree fits provide smoothing, while a fit of degree one less than the window size simply interpolates the data. Derivatives of the fitted polynomial similarly give numerical differentiation formulas.

For local distinct real abscissas x_1, x_2, ..., x_N, choose orthogonal polynomials p_k(x) of polynomial degree k for the discrete inner product <p_j,p_k>=sum_(i=1)^(N)p_j(x_i)p_k(x_i). For d<N and 0<=s<=d, the sth derivative of the fitted polynomial at t is

 f_d^((s))(t)=sum_(i=1)^Nw_i^((s))(t)y_i,
(1)

with weights

 w_i^((s))(t)=sum_(k=0)^d(p_k(x_i)p_k^((s))(t))/(gamma_k),
(2)

where gamma_k=sum_(j=1)^(N)[p_k(x_j)]^2 (Gorry 1990, 1991). Evaluating the first and last windows away from their centers retains estimates at the endpoints instead of discarding them (Gorry 1990). For unequally spaced data, the local weights generally depend on the locations of the data points, so a single translation-invariant convolution stencil does not in general apply (Gorry 1991).

For example, take five equally spaced samples y_j at offsets jh from the window center, where j=-2, -1, 0, 1, 2 and h>0. A quadratic polynomial q(t) fitted to these samples gives

q(0)=(-3y_(-2)+12y_(-1)+17y_0+12y_1-3y_2)/(35)
(3)
q^'(0)=(-2y_(-2)-y_(-1)+y_1+2y_2)/(10h).
(4)

See also

Filter, Numerical Differentiation

Explore with Wolfram|Alpha

References

Gorry, P. A. "General Least-Squares Smoothing and Differentiation by the Convolution (Savitzky-Golay) Method." Anal. Chem. 62, 570-573, 1990. https://doi.org/10.1021/ac00205a007.Gorry, P. A. "General Least-Squares Smoothing and Differentiation of Nonuniformly Spaced Data by the Convolution Method." Anal. Chem. 63, 534-536, 1991. https://doi.org/10.1021/ac00005a031.Press, W. H.; Flannery, B. P.; Teukolsky, S. A.; and Vetterling, W. T. Numerical Recipes in FORTRAN: The Art of Scientific Computing, 2nd ed. Cambridge, England: Cambridge University Press, pp. 183 and 644-645, 1992.Savitzky, A. and Golay, M. J. E. "Smoothing and Differentiation of Data by Simplified Least Squares Procedures." Anal. Chem. 36, 1627-1639, 1964. https://doi.org/10.1021/ac60214a047.

Referenced on Wolfram|Alpha

Savitzky-Golay Filter

Cite this as:

Weisstein, Eric W. "Savitzky-Golay Filter." From MathWorld--A Wolfram Resource. https://mathworld.wolfram.com/Savitzky-GolayFilter.html

Subject classifications