什么是R的模拟filter在 NumPy 中?
我有以下 R 代码:
f <- rep(1/9, 9)
smth_x <- filter(x, f, sides=2)
其中 x 是一些可能包含 nan 的一维时间序列向量。
如何使用 NumPy 执行相同的操作? (或任何其他 python 库)
请您参考如下方法:
我认为 scipy filter functions做你想做的,特别是lfilter .来自 this HOWTO :
import numpy, scipy.signal
taps = numpy.repeat(1.0/9, 9)
smoothed_x = scipy.signal.lfilter(taps, 1.0, x)
