Created
July 25, 2017 07:32
-
-
Save sa2812/1cc7889f10c4d340faf68cbe78fd94b9 to your computer and use it in GitHub Desktop.
Strides with rolling window
This file contains 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
def rolling_window(self, ts, window, stride): | |
shape = ts.shape[:-1] + (int((ts.shape[-1] - window)/stride + 1), window) | |
strides = (stride*ts.strides[-1],) + (ts.strides[-1],) | |
return np.lib.stride_tricks.as_strided(ts, | |
shape=shape, | |
strides=strides) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment