移动平均值或运行平均值对于python,是否存在计算给定特定窗口的一维数组的运行均值的cip函数或numpy函数或模块?
3 回答
慕盖茨4494581
TA贡献1850条经验 获得超11个赞
mylist = [1, 2, 3, 4, 5, 6, 7]N = 3cumsum, moving_aves = [0], []for i, x in enumerate(mylist, 1): cumsum.append(cumsum[i-1] + x) if i>=N: moving_ave = (cumsum[i] - cumsum[i-N])/N #can do stuff with moving_ave here moving_aves.append(moving_ave)
添加回答
举报
0/150
提交
取消