I know how to find the indices of the maximum element of an n-dimensional array.
Let's have for example:
a=np.asarray([[1,7,-4],[9,-11,-17]])
Then (source):
from numpy import unravel_index
unravel_index(a.argmax(), a.shape)
returning:
(1, 0)
and indeed a[1,0] is 9, which is the highest element in the array a, so we are good.
I am also able to figure out how to find the indices of the ith largest element of a one-dimensional numpy array (using):
a = np.array([1, 3, 2, 4, 5])
i=3 # we want the third largest element, for example
a.argsort()[-i]
This returns 1, which is good, since a[1]=3 which is indeed the third largest element of a.
I would like to combine these two. So if I have
a=np.asarray([[1,7,-4],[9,-11,-17]])
I would like to get an output telling me the indices of the ith largest element of the array a, for example if i=3, the output should be [0,0], since a[0,0]=1 is the ith (third) largest element of a.
How can I do this?