Given an array I need to find the minimum and the position of the minimum. 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 solutions is not very efficient because it needs to scan the list two times. Is there a way to obtain minimum and agrmin at the same time?
min_pos = current_cost.argmin()
min_val = current_cost[min_pos]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With