mattools.py 文件源码

python
阅读 54 收藏 0 点赞 0 评论 0

项目:finance_news_analysis 作者: pskun 项目源码 文件源码
def get_mat_ewma(tsmat, alpha):
    # EWMA(t) = alpha * ts(t) + (1-alpha) * EWMA(t-1)
    ewma = np.tile(np.NAN, tsmat.shape)
    for i in xrange(1, tsmat.shape[0]):
        init_selection = np.isnan(ewma[i-1, :])
        ewma[i-1, init_selection] = tsmat[i-1, init_selection]
        ewma[i, :] = alpha * tsmat[i, :] + (1-alpha) * ewma[i-1, :]
    return ewma
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号