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>1. This function return a Numpy array of dim (k,1).
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
Of course I can do a for loop but it is very slow.
I found this function on internet but I don't know how to call my function on this:
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)
How can I optimise this sort of problem ?