SHARE
TWEET

Python - Exponentially weighted moving average

furas Jun 24th, 2018 18 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import matplotlib.pyplot as plt
  2.  
  3. # Exponentially weighted moving average
  4. # https://medium.com/@abhinav.mahapatra10/beginners-ml-basics-exponentially-weighted-moving-average-8ce3e75768f6
  5.  
  6. data1 = [25, 28, 26, 22, 19, 23, 27]
  7. data2 = []
  8.  
  9. a = 0.2
  10. b = 1-a
  11.  
  12. s = data1[0]
  13. data2.append(s)
  14.  
  15. for x in data[1:]:
  16.     s = a*x + b*s
  17.     data2.append(s)
  18.    
  19. plt.plot(data1)
  20. plt.plot(data2)
  21.  
  22. plt.show()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top