Guest User

Untitled

a guest
Jun 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. import numpy as np
  2.  
  3. def movingaverage (values, window):
  4. weights = np.repeat(1.0, window)/window
  5. sma = np.convolve(values, weights, 'valid')
  6. return sma
  7.  
  8. x = [1,2,3,4,5,6,7,8,9,10]
  9. y = [3,5,2,4,9,1,7,5,9,1]
  10.  
  11. yMA = movingaverage(y,3)
  12. print (yMA)
Advertisement
Add Comment
Please, Sign In to add comment