如何使用 Savitzky-Golay 平滑系数计算导数

发布于 2024-09-15 16:44:46 字数 204 浏览 3 评论 0原文

Savitzky-Golay 平滑滤波器可用于计算系数,以便通过将系数应用于相邻值来计算平滑的 y 值。平滑的曲线看起来很棒。

根据论文,这些系数还可以用于计算高达五阶的导数。系数计算参数 ld 需要设置为导数的阶数。对于一阶导数,合适的设置是ld=1,导数的值是累加和除以采样间隔h。

我的问题是:如何用得到的系数来计算累加和?导数是如何计算的?有示例代码吗?

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 sum? how is the derivative calculated? any sample code?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花间憩 2024-09-22 16:44:46

要使用 Savitzky-Golay 平滑滤波器计算导数,多项式系数计算有一个参数 b,值 b[derivative] 必须设置为 1.0,数组 be 将在 LU 分解调用中使用。

正确求导的关键是理解多项式公式:Y = a0 + a1 * z + a2 * z^2 + ... + ak * z^k。 a0, a1, a2, ..., ak 值实际上是移动窗口内的平滑值,z = (x - x0) / h,对于移动窗口的中心点,我们可以假设 z = 0,因为 x = x0。

因此,在导数计算中:

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

其中a1、a2是使用相应导数计算的系数对y进行平滑后的值。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文