Numpy: convert index in one dimension into many dimensions
numpy, scipy
Solution
Got it!
a = X.argmax()
(i,j) = unravel_index(a, X.shape)
Problem
Many array methods return a single index despite the fact that the array is multidimensional. For example: ``` a = rand(2,3) z = a.argmax() ``` For two dimensions, it is easy to find the matrix indices of the maximum element: ``` a[z/3, z%3] ``` But for more dimensions, it can become annoying. Does Numpy/Scipy have a simple way of returning the indices in multiple dimensions given an index in one (collapsed) dimension? Thanks.