Savitzky-Golay smoothing filter can be used to calculate the coefficients so as to calculate the smoothed y-values by applying the coefficients to the adjacent values. The smoothed curve looks great.
According to the papers, the coefficients can also be used to calculate the derivatives up to 5th order. The coefficients calculation parameter ld would need to be set to the order of derivatives. For the first derivative, the appropriate 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 s开发者_StackOverflow社区um? how is the derivative calculated? any sample code?
To calculate the derivatives using Savitzky-Golay smoothing filter, the polynomial coefficients computation has a parameter b, the value b[derivative] must be set to 1.0, the array be will be used in the LU decomposition call.
The key to get derivatives right is to understand the polynomial formula: Y = a0 + a1 * z + a2 * z^2 + ... + ak * z^k. The values a0, a1, a2, ..., ak are actually the smoothed values within the moving window, z = (x - x0) / h, for the centre point of the moving window, we can assume z = 0 since x = x0.
Therefore, in the derivative calculations:
dY/dx = a1/h; and d2Y/dx2 = 2a2/h^2.
Where a1, a2 are the smoothed values of y by using the coefficients calculated on the corresponding derivatives.
精彩评论