Change moving_window to much more general scipy.signal.convolve