Numerical differentiation of a list in mathematics

How can I differentiate a numerical list in Mathematica without first fitting it to a mathematical expression (i.e. using FindFit )?

In particular, I would like to find the point of maximum slope in the list.

I looked at using Differences and finding the maximum difference, but the noise in the data makes this inaccurate. Smoothing data using MovingAverage does not help either.

Thanks in advance.

+7
source share
1 answer

You can try ListConvolve with a Gaussian kernel to smooth your data. One of the nice things about this is that the derivative of the convolution with a Gaussian kernel is equivalent to coagulation with the derivative of a Gaussian kernel.

Here are some sample data:

 data = Table[Sin[x] + .5 RandomReal[{-1, 1}], {x, 0, 6 \[Pi], .05}]; ListLinePlot[data] 

enter image description here

This is a simple convolution with a Gaussian kernel:

 data2 = Block[{\[Sigma] = 2}, ListConvolve[ Table[1/(Sqrt[2 \[Pi]] \[Sigma]) E^(-x^2/(2 \[Sigma])), {x, -2 , 2, 1/10} ], data, {11, 11} ] ]; ListLinePlot[data2] 

enter image description here

Convolution with the first derivative of Gaussian:

 data3 = Block[{\[Sigma] = 1}, ListConvolve[ Table[-((E^(-(x^2/(2 \[Sigma]))) x)/(Sqrt[2 \[Pi]] \[Sigma]^2)), {x, -2 \[Sigma],2 \[Sigma], \[Sigma]/10} ], data, {11, 11} ] ]; ListLinePlot[data3] 

enter image description here

You might want to play with the sigma parameter to find out which results are optimal in your case.

This whole theory is called Scale Space . Note that the convolution statement above is valid for continuous space. For a discrete implementation, the kernel can be chosen slightly better.

Note that, like MovingAverage, convolution can move the functions of your data.

+6
source

All Articles