slope of curve represented by discrete points

3.1k Views Asked by At

I have data which are visualized in this chart: enter image description here

I need to compute slope of increasing / decreasing parts of the curve. I can't use any 2 points because of noise in data. Maybe numerical derivative can help but I don't know how to use it.

EDIT Spline Interpolation from Mathematica of axis Y(green line)

2

There are 2 best solutions below

2
On BEST ANSWER

Numerical derivative looks reasonable to me. You can choose a one-sided finite difference $y'(n)\approx \frac{x(n+h)-x(n)}{h}$ or a symmetric one, $y'(n)\approx \frac{x(n+h)-x(n-h)}{2h}$. The second one preserves symmetry and is better for most situations where you only need a derivative, not for solving equations. The one-sided can use the left or the right neighbour.

The derivative always increases the noise but it is misleading to interpolate! Interpolation only makes up information that isn't there. You can get data that no longer satisfies correct statistical properties, inequalities and can lead to misuse.

It makes a bit more sense to smooth after taking the discrete derivative. The entire information is still there. If you know that high frequency noise is not a physical thing, you can filter later: any low-pass filter can be used (either by running average or any builtin smoothing methods).

If you have periodic data, or if you have enough zeros on the left and the right (or if you premultiply with a window function), you can use fourier transform to take the derivative. Perform FFT, and in the Fourier space, differentiation equals multiplication by frequency and imaginary unit. Then just transform back. This is a bit better in a sense, that doesn't really treat the derivative as a local operator, but takes into account the "big picture" and thus may be a bit more stable. This is a good method if you want to filter, because you can do it both at the same time: just multiply by the frequency filter before inverting the transform.

0
On

y′(n)≈x(n+h)−x(n)/h, y′(n)≈x(n+h)−x(n)h, and y′(n)≈x(n+h)−x(n−h)/2h are only good approximations to a derivative when the signal is grossly oversampled, meaning that the frequency content is composed of low frequencies. Compute the spectrum and compare it to what a real differentiator would do.

This is an all-to-common mistake.