Home > Enterprise >  Getting 10 nsmallest arrays from a set of arrays
Getting 10 nsmallest arrays from a set of arrays

Time:10-28

First of all, I apologize for the confusing title, the task which I'm trying to accomplish is itself still confusing to me, hence why I'm finding it hard to do it. I'll try to be as clear as I can from now on.

I have 100 500x500 arrays, the values inside range from 0 to 1. What I would like to do is write a code that gives me 10 arrays, these arrays will be a sort of composite of the minimum values between them.

The first array is made of the absolute minimum values, the second array with the 2nd order minimum values....and so on. So the 10 arrays will be a composite of sorted ascending values.

I managed to get the absolute minimum with np.minimum() but I have no clue on how to proceed to the next ones.

To reiterate, I don't want to sort the 100 arrays, but loop through them and create new arrays with the lowest values found in each position.

CodePudding user response:

Sorting is the most efficient way.

np.sort([array0,array1,...], 0)

Will yield an array where the first element is an 100x100 array of the smallest element-wise entries of all your arrays, the second the second smallest, etc.

  • Related