def get_mat_movingstd(tsmat, periods):
mstd = np.empty(shape = tsmat.shape)
mstd.fill(np.NAN)
for i in xrange(tsmat.shape[0]):
j = i - periods + 1
if j < 0:
j = 0
mstd[i,:] = np.nanstd(tsmat[j:i+1,:], 0)
return mstd
评论列表
文章目录