I want to mention upfront that I'm not very experienced in this field.

I have a signal $u(k)$ that I get from a black box simulation (sampled irregularly). The signal looks like this:

enter image description here

The blue signal has small frequency oscillations that i want to remove. The orange curve was obtained by fitting a polynomial on the whole dataset.

My goal is to obtain a smooth estimate of the blue signal in real-time (streaming data) and then compute its derivative. Is it possible to obtain something as smooth as the orange curve ?

If so, can you suggest some commonly used methods ?

  • 2
    $\begingroup$ Hi, welcome to DSP.SE! Does this answer your question? $\endgroup$ Jul 17, 2023 at 16:09
  • $\begingroup$ Search this site and the internet for Savitzky-Golay filters. There's also a Savitzky-Golay differentiator. $\endgroup$
    – Matt L.
    Jul 17, 2023 at 16:32

1 Answer 1


You may have few options:

  1. On Line Least Squares
    You may use the Sequential Least Squares (MATLAB Code available in the link).
    This will give you exactly what you got using the polynomial model.
    Since it is a polynomial model, you will be able to calculate the derivative on line as well.
  2. Savitzky Golay Filter
    Those filter with pre defined coefficients approximate the polynomial Least Squares solution locally.
    They also have a variant to calculate the derivative on line.
    Since they are online they are even more sensitive to outliers (Locally) than the global Least Squares.
  3. Kalman Filter
    You may use the Kalman Filter to have online estimation both of the smooth curve and its local derivative.

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