2
$\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.

$\endgroup$
2
  • 1
    $\begingroup$ A description and routine is given in Numerical Recipes: fizyka.umk.pl/nrbook/c14-8.pdf $\endgroup$ Commented Nov 5, 2010 at 18:39
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Nov 6, 2010 at 2:14

1 Answer 1

3
$\begingroup$

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.

$\endgroup$
4
  • $\begingroup$ 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? $\endgroup$
    – snmcdonald
    Commented Nov 5, 2010 at 23:58
  • $\begingroup$ 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? $\endgroup$
    – snmcdonald
    Commented Nov 6, 2010 at 0:10
  • 1
    $\begingroup$ @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. $\endgroup$ Commented Nov 6, 2010 at 0:21
  • 2
    $\begingroup$ 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. $\endgroup$ Commented Nov 6, 2010 at 0:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .