I am pretty sure this has already been asked and it has to do with numpy.choose, but I cannot figure out how it is accomplished. Consider the following:
N_t = 1000
N_d = 10
X = np.random.random([N_d,N_d,N_t])
jumps = np.random.randint(N_d,size = N_t)
jumps[0] = 0
f = [X[jumps[t],jumps[t-1],t] for t in range(1,N_t)]
Is there a "numpy"-way of constructing f? (Side remark: X is some kind of transition matrix and jumps are the indices of some jump-trajectory in a d-dim state space.