Scipy implementation of Savitzky-Golay filter

不羁岁月 提交于 2019-12-01 23:21:34

Indeed, this logic isn't right, which can be best seen by considering the case of y[0] and y[-1] being 0. I believe the intent was to achieve odd reflection, so that the first derivative would be continuous at the reflection point. The correct form for that is

firstvals = 2*y[0] - y[1:half_window+1][::-1]
lastvals = 2*y[-1] - y[-half_window-1:-1][::-1]

or, combining reversing and slicing in one step,

firstvals = 2*y[0] - y[half_window:0:-1]
lastvals = 2*y[-1] - y[-2:-half_window-2:-1]

I should emphasize this is just some code contributed by a user. The actual Scipy implementation of Savitzky-Golay filter is entirely different.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!