1
$\begingroup$

I am working on a signal-smoothing algorithm for personal interest. I understand the basic concept of the Savitzky-Golay algorithm but I would like to understand how the coefficients were discovered. Can someone please explain the the mathematics behind it, so I could calculate the coefficients on my own?

How would the matrix look? For example here states: "For n=5 and p=3, the filtering coefficients are b= [-0.0857 0.3429 0.4857 0.3429 -0.0857]." However, it does not show the steps to achieve this. If n equal the number of points to sample and p equals the power of the polynomial.

  • 1
    A description and routine is given in Numerical Recipes: http://www.fizyka.umk.pl/nrbook/c14-8.pdf2010-11-05
  • 1
    There's a better derivation in Hildebrand; read the whole chapter on polynomial fitting first so you can understand how the smoothing coefficients are calculated.2010-11-06

1 Answers 1

2

This was supposed to be a comment, but it got too long.

I'm personally not too enamored of the NR routine for Savitzky-Golay myself; it has to use Gaussian elimination (and thus a two-dimensional array) for what I think is a well-structured problem. Peter Gorry's proposal in this paper is a better choice, IMHO (a proper implementation merely requires a few one-dimensional arrays; see here for a Mathematica implementation). In any event, looking at the original article by Savitzky and Golay should help you a great deal, as well as F.B. Hildebrand's Introduction to Numerical Analysis; Hildebrand does not explicitly refer to the Savitzky-Golay coefficients, but he gives the general idea of using least-squares fit polynomials for smoothing data.

  • 0
    If I understand correctly would I be able to say that Savitzky-Golay's algorithm is a least squares of polynomials applied with the framing of moving average?2010-11-05
  • 0
    Secondly does the least square have to be applied to each frame or can coefficients be calculated based upon the number of elements you want to frame?2010-11-06
  • 1
    @Shiftbit: Well, the underlying assumption is that the data are equispaced (if your data is sampled at regular intervals, then this assumption is satisfied). You can think of it as a more elaborate version of the moving average, except that the weights are chosen such that it is as if you performed a least-squares polynomial fit in each window, but done more efficiently.2010-11-06
  • 2
    As a matter of fact, if you won't be varying the window size and polynomial degree, you don't even need to supply a Savitzky-Golay routine; you can just use it to compute the needed coefficients for the window just once, store those coefficients in an array, and convolve as you please.2010-11-06