Derivative of noisy signal

My input signal is phase vector. I want to differentiate it to get frequency vector. My input signal is somewhat noisy. Here is the input signal.

This is the derivative of the input signal as calculated using

diff(inputSig)


When i differentiate this signal, I am not getting a smooth curve. The output looks 'spikey'. I am guessing it is because of the noise in the input signal (is this 'derivative kick'?). How to avoid this and get a smooth derivative curve?

• Can you provide the data so we can experiment ? – Sektor May 27 '14 at 10:40
• Sorry but I cannot. Have some firewall restrictions – BaluRaman May 27 '14 at 10:44
• Are you sure that your derivative is correct? I can't see any value change in the picture at the top of around 125, so I have doubts that the second picture is really the derivative of the one above. – bonanza May 27 '14 at 19:38
• This answer may help: dsp.stackexchange.com/a/9512/35 – datageist May 27 '14 at 23:12
• For accurate results, you should not consider this diff() to be your choice. Basically this function subtracts two values. Check the documentation of Matlab. I'm assuming you are using Matlab though. – CroCo Jun 2 '14 at 1:00

2 point discrete differentiation is bound to produce highly noisy results. try the 5-points stencil. you can also generate coefficients (i.e. more points) yourself using derivation of Lagrange polynomials.

Look into the "Savitsky Golay Differentiation Filter"

• Didnt solve the problem. I am using 'sgolayfilt' in Octave to smooth the input data and taking derivative after smoothing. Still getting spikes in the derivative result. Tried increasing order of the polynomial but its not working – BaluRaman May 27 '14 at 13:21
• I think what you want is a filter function that returns the differentiation filters, for example see mathworks.com/help/signal/ref/sgolay.html -- it looks like Octave may not have this feature. – John May 27 '14 at 15:23

You can find the wavelet transform and use derivatives of wavelets. In this spirit, there is a procedure to directly calculate derivatives based on them. The beauty of the wavelet transform is that you should be able to discard high-frequency components, theoretically coming from the underlying noise and sampling rate.

If you can get your hands on this and this, for example, you should be able to apply them.

Try boxcar line fitting with different length of times. This method filters and smooths the derivative

You can apply the concept of "scale" to your original data. The original data can be considered at the "finest" or "smallest" scale in the sense that all details are available to you. But you might not be interested in this level of detail since it might have noise that is affecting you.

If you convolve your original data with a Gaussian (normalized) of a given size, then you are effectively smoothing your signal and looking at a "larger scale". By choosing different "sigma" (width) of your gaussian, you can smooth your signal, hence its derivative.

You could start with a small sigma of 5-10 and see if the smoothing is sufficient for you.