I believe you can do it this way, but maybe there is a better way.
n = 10 F = np.tile(np.arange(0,n,0.1)[None,None,:,None,None], [n, n, 1, n, n]) X = np.tile(np.arange(0,n)[None,None,:,None], [n, n, 1, n]) a,b,c,d = np.ogrid[:n,:n,:n,:n] argmaxD = F[a,b,c,d,X].argmax(axis=-1)
Above X does not occupy all the space, as we discussed in the comments. If you want to select e for all a , b , c and d , you can do, for example:
X = np.tile(np.arange(0,n,0.1).astype(int)[None,None,:,None], [n, n, 1, n]) a,b,c,d = np.ogrid[:n,:n,:100,:n] argmaxD = F[a,b,c,d,X].argmax(axis=-1)
Also note that you can use translation instead of tile . But then F[a,b,c,d,X] has a special size, so you should provide something like axis=3 :
X = np.arange(0,n,0.1).astype(int)[None,None,:,None] a,b,c,d = np.ogrid[:n,:n,:100,:n] argmaxD = F[a,b,c,d,X].argmax(axis=3)