3
$\begingroup$

I am trying to smooth a series of data in order to obtain a continuous function that could represent that given data set. It came out that the Savitzky-Golay method could be a good way.

Now, I don't know much about smoothing and/or interpolate, but I managed to obtain a good result, at a first glance: enter image description here The blue points are my data, and the red line is the result from a SG filter applied with a window = 15 and a polynomial order = 13. Now, I could try some other combinations of window&order, but more generally I would like to know the principles of the best meeting of these two parameters, especially in my case, where the data have no smooth trend (like a sinusoidal).

$\endgroup$
3
$\begingroup$

Let's call the window length $M$, and $N$ is the order of the polynomial. One important thing to realize is that you use a polynomial of order $N$ to approximate $M$ data points. This means that you use $M$ points to compute $N+1$ polynomial coefficients (an $N^{th}$ order polynomial has $N+1$ coefficients). So if $N+1=M$ then you do not smooth at all but you just use the polynomial to interpolate the data points. In your example this is almost the case, i.e. there is hardly any smoothing. Generally, $N$ is chosen considerably smaller than $M$ to achieve some smoothing (and also for numerical stability). The smaller $N$ compared to $M$, the more smoothing you will get. What remains is the choice of $M$, but as far as I know there are no general guidelines. In practical examples I've seen polynomial orders of $4$ or $5$ with much larger values for $M$. With all this in mind it remains to try several combinations of $M$ and $N$ and choose the one that fits best your application.

$\endgroup$
  • $\begingroup$ Indeed, I can obtain the same result with a polynomial order much smaller $\sim 5$, but with a window size $<13$ otherwise the smoothed model become too unrepresentative of the features of the original pattern. What do you mean by considerably smaller? Is it included in the number I have just posted? $\endgroup$ – Py-ser Apr 16 '14 at 5:51
  • $\begingroup$ @Py-ser Yes, the window size is often chosen more than a factor 2 greater than the polynomial order. How much of a difference between $N$ and $M$ is desired, depends on the data and the amount of desired smoothing. $\endgroup$ – Matt L. Apr 16 '14 at 6:56
0
$\begingroup$

The choice of parameters depends also on the nature of the phenomena you want to smooth. It has a characteristic spectra? it is changing fast or slowing? all this information can help you to setup order (lower values are not able to cope with high rate changing phenomena) and window (size of the window is related to the frequency of the phenomena)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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