Min and argmin in numpy

Given the array, I need to find the minimum and minimum position. This can be done using

>>> current_cost array([ 2.54802261, 2.98627555, 0.23873749, 1.82511195, 1.35469083]) >>> current_cost.min() 0.23873748917821858 >>> current_cost.argmin() 2 

This solution is not very effective because it needs to double check the list. Is there a way to get minimum and agrmin at the same time?

+5
source share
1 answer
 min_pos = current_cost.argmin() min_val = current_cost[min_pos] 
+9
source

Source: https://habr.com/ru/post/1203541/


All Articles