This sounds like a standard question to me but I haven't found any answer so far, looking on a hundred sites.

We have a time series (say >100 x and y values, x equidistant) representing a smooth curve plus gaussian noise. We want to estimate a) the smooth curve and b) its first and second derivatives. Currently we apply a gaussian kernel smoother but we run into trouble at the edges, so we want to switch to a kernel with finite support.

For a) I understand that the Epanechnikov kernel is optimal in a way but biweight or triangular are not much worse.

Regarding b) we have no idea. Is there an equivalently good / robust / established solution to find smooth derivatives?


Take a look at Savitzky-Golay filters. They work by sliding a window across the time series. A local polynomial model is fit to the signal in each window using least squares. Evaluating the model at the center of each window gives a smoothed version of the signal. It's also possible to differentiate the model to obtain smoothed derivatives, second derivatives, etc. If you want second derivatives, you'd have to use at least a local quadratic model, of course. You could think of a simple moving average as a 0th order Savitzky-Golay filter.

Using at least a local linear model, there are no edge effects. It's possible to use these filters with non-uniformly spaced samples. When the samples are uniformly spaced, computation is very efficent--both smoothing and differentiation can be performed by convolving the signal with particular FIR filter coefficients. But, to avoid edge effects in this case, it's necessary to iterate through points at the edges of the signal.

Savitzky-Golay filters are a popular tool, so it should be easy to find an implementation in your language of choice.


I had good results with simple median filter. Our task is to analyze eye movements. Recordings of eye position are performed each 1 ms. We are interested in gaze velocity. Obviously, it is an equidistant very noisy signal, from which we should obtain a derivative. We try several different filters, the best was moving median filter. Before differentiating the filtered signal we average equal neighbors (remove all equal values and place one on the middle of period of equality). After this step we obtained rather pretty derivative.

  • $\begingroup$ This is being automatically flagged as low quality, probably because it is so short. At present it is more of a comment than an answer by our standards. Can you expand on it? We can also turn it into a comment. $\endgroup$ – gung - Reinstate Monica Jan 21 '17 at 0:17
  • $\begingroup$ I can guarantee you have not had good results using a median filter for finding smooth derivatives! Such a filter is the opposite of smooth: it will jump discontinuously as the window moves. $\endgroup$ – whuber Jan 21 '17 at 0:25
  • $\begingroup$ I posted this answer from mobile app. For some reasons it allows me to comment only my answers. Sorry :) $\endgroup$ – zlon Jan 21 '17 at 7:41

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.