Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def movingaverage (values, window):
- weights = np.repeat(1.0, window)/window
- sma = np.convolve(values, weights, 'valid')
- return sma
- x = [1,2,3,4,5,6,7,8,9,10]
- y = [3,5,2,4,9,1,7,5,9,1]
- yMA = movingaverage(y,3)
- print (yMA)
Advertisement
Add Comment
Please, Sign In to add comment