Skip to content

Instantly share code, notes, and snippets.

@kashefy
Last active July 29, 2016 13:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kashefy/91236b3ebf676bc786b7c63840d274f3 to your computer and use it in GitHub Desktop.
Save kashefy/91236b3ebf676bc786b7c63840d274f3 to your computer and use it in GitHub Desktop.
Moving average for a time series
import numpy as np
def moving_avg(x, window_size):
window = np.ones(int(window_size)) / float(window_size)
return np.convolve(x, window, 'valid')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment