(S,N)
| 43 | return pd.Series(S).ewm(alpha=M/N,adjust=False).mean().values #com=N-M/M |
| 44 | |
| 45 | def AVEDEV(S,N): #平均绝对偏差 (序列与其平均值的绝对差的平均值) |
| 46 | avedev=pd.Series(S).rolling(N).apply(lambda x: (np.abs(x - x.mean())).mean()) |
| 47 | return avedev.values |
| 48 | |
| 49 | def SLOPE(S,N,RS=False): #返S序列N周期回线性回归斜率 (默认只返回斜率,不返回整个直线序列) |
| 50 | M=pd.Series(S[-N:]); poly = np.polyfit(M.index, M.values,deg=1); Y=np.polyval(poly, M.index); |