How to use the Savitsky-Naked smooth coefficient to calculate derivatives

The Savitsky-Naked Smoothing Filter can be used to calculate coefficients to calculate smoothed y values ​​by applying coefficients to adjacent values. The smoothed curve looks great.

According to documents, coefficients can also be used to calculate derivatives up to 5th order. The parameter for calculating the coefficients ld must be set in the order of derivatives. For the first derivative, the corresponding setting is ld = 1, and the value of the derivative is the accumulated sum divided by the sampling interval h.

My question is: how to use the obtained coefficients to calculate the accumulated amount? How is the derivative calculated? any sample code?

+6
c ++ smoothing derivative
source share
1 answer

In order to calculate derivatives using the Savicki-Naked smoothing filter, the calculation of polynomial coefficients has the parameter b, the value b [derivative] must be set to 1.0, the array will be used in the LU decomposition call.

The key to obtaining the right to derivatives is understanding the polynomial formula: Y = a0 + a1 * z + a2 * z ^ 2 + ... + ak * z ^ k. The values ​​a0, a1, a2, ..., ak are actually smoothed values ​​in the moving window, z = (x - x0) / h, for the central point of the moving window we can assume z = 0, since x = x0.

Therefore, in derivative calculations:

dY/dx = a1/h; and d2Y/dx2 = 2a2/h^2. 

Where a1, a2 are the smoothed y values ​​using the coefficients calculated for the corresponding derivatives.

+2
source share

All Articles