Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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.

share|improve this question
1  
A description and routine is given in Numerical Recipes: fizyka.umk.pl/nrbook/c14-8.pdf –  Ross Millikan Nov 5 '10 at 18:39
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. –  J. M. Nov 6 '10 at 2:14

1 Answer 1

up vote 2 down vote accepted

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). 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.

share|improve this answer
    
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? –  snmcdonald Nov 5 '10 at 23:58
    
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? –  snmcdonald Nov 6 '10 at 0:10
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. –  J. M. Nov 6 '10 at 0:21
1  
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. –  J. M. Nov 6 '10 at 0:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.