dqn_features.py 文件源码

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

项目:tensorflow-stock-prediction 作者: weitingforyou 项目源码 文件源码
def get_moving_average(x, n, type_str):
    #compute an n period moving average.
    #type is 'simple' | 'exponential'
    my_list=[]
    x = np.asarray(x)
    if type_str == 'simple':
        weights = np.ones(n)
    elif type_str == 'exponential':
        weights = np.exp(np.linspace(-1., 0., n))
    elif type_str == 'weight':
        weights = np.flipud(np.arange(1,n+1, dtype=float))
    weights /= weights.sum()

    a = np.convolve(x, weights, mode='full')[:len(x)]
    a[:n] = a[n]
    for i in xrange (0, len(a), 1):
        my_list.append(np.array_str(a[i]))
    return my_list
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号