title: Smooth first derivative of noisy input signal
body: <p>I have attached images of an input signal (shown in blue), which is actually a continuous input stream and whose trend I do not know, and the signal smoothed using a moving average filter of span 5 (shown in red). </p>
  
  <p><strong>Raw input and smoothed input signal</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/77hNq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/77hNq.png" alt="enter image description here"></a></p>
  
  <p><strong>First derivative of the raw input and smoothed input signal</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/8Rc52.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8Rc52.png" alt="enter image description here"></a></p>
  
  <p>My aim is to calculate the ratio of this signal to its first derivative. However, clearly the first derivative is noisy and does not give good results. I realize I must change the filter from moving average to a more robust one. <br>I have looked up Savitzky-Golay filter, but I read on another site that it is more efficient in retaining the shape of the signal than reducing the noise. <a href="http://terpconnect.umd.edu/~toh/spectrum/Smoothing.html" rel="nofollow noreferrer">http://terpconnect.umd.edu/~toh/spectrum/Smoothing.html</a></p>
  
  <p>Kalman filter would be my next guess but it needs an initial state estimate which I cannot know for this type of signal.</p>
  
  <p>Any other suggestions on how to smooth the first derivative of a noisy input?</p>