Last active
July 29, 2016 13:06
-
-
Save kashefy/91236b3ebf676bc786b7c63840d274f3 to your computer and use it in GitHub Desktop.
Moving average for a time series
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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