In numpy, I can find which 2D array is the least of all 3 2D arrays as follows:
mat_a = np.random.random((5, 5))
mat_b = np.random.random((5, 5))
mat_c = np.random.random((5, 5))
bigmat = np.stack((mat_a, mat_b, mat_c)) # this is a 3, 5, 5 array
minima = np.argmin(bigmat, axis=0) # contains a 5x5 array of 0,1,2 for a,b,c respectively
How do I extend this, so that it works to find 2nd least of all 3 2D arrays?
-- EDIT:
Expected output is a 5 x 5 numpy array, where each element is represents which of the 3 arrays (mat_a, mat_b, mat_c) is the 2nd least value in bigmat.
So, structure will be same as minima
, except minima
can only show which array is least.