我正试图对加速度计数据(x加速度(ax),y加速度(ay),z加速度(az))实施低通滤波器优化用于活动识别的低通滤波器平滑代码
我已经计算我的阿尔法为0.2
沿x方向DC分量使用公式
new_ax [N] =(1-α)* new_ax [N-1] +(阿尔法*计算ax [n])
我可以计算出这个数据集有几千条记录。但是我有一个包含一百万条记录的数据集,并且需要永久运行下面的代码。我会很感激任何帮助即兴编写我的代码的时间复杂性。
### df is a pandas dataframe object
n_ax = []
seq = range(0, 1000000, 128)
for w in range(len(seq)):
prev_x = 0
if w+1 <= len(seq):
subdf = df[seq[w]:seq[w+1]]
for i in range(len(subdf)):
n_ax.append((1-alpha)*prev_x + (alpha*subdf.ax[i]))
prev_x = n_ax[i]
另请参见http://stackoverflow.com/questions/21336794/python-recursive-vectorization-with-timeseries和http://stackoverflow.com/questions/21391467/can-i-use-numpy-to-speed -this-loop –
@Warren:感谢您指引我进入正确的页面。 – user1946217