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
dqn_features.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录