title: Is there a way to optimise a rolling function calculation?
body: <p>my problem is simple. I have a function f(y,x) where y is of dim (T,1) and x of dim (T,k) with k&gt;1. This function return a Numpy array of dim (k,1).</p>
  <p>From this I would like to calculate f function on a rolling basis ie :
  result[i] = f(y[i-window],x[I-window]), i=window+1, T</p>
  <p>Of course I can do a for loop but it is very slow.</p>
  <p>I found this function on internet but I don't know how to call my function on this:</p>
  <pre><code>def rolling_window(a, window):
      shape = a.shape[:-1] + (a.shape[-1] - window + 1, window)
      strides = a.strides + (a.strides[-1],)
      return np.lib.stride_tricks.as_strided(a, shape=shape, strides=strides)
  </code></pre>
  <p>How can I optimise this sort of problem ?</p>