How can I find minimum of array of floats in Python? The min() or array.min() did not work. Here is the code:
import numpy as np
z=np.array([[ -4.26141957e-01],
[ -2.26582552e-01],
[ -7.28807682e-03],
[ 2.72843324e-02],
[ -5.59146620e-02],
[ -2.06062340e-05],
[ 1.06954166e-09],
[ -6.34170623e-01],
[ 5.07841198e-02],
[ -1.89888605e-04]])
z_min=z.min()
which gives z_min = -0.63417062312627426. I am a Matlab user so this is confusing to me...
z[np.abs(z).argmin()]the number with the least magnitude?-0.634 < -0.0559is true, isn't it? Then-0.634is smaller — that's howmin()works.-10 < -1Right? Try it in Matlab, too. You'll get the same result. It's just how negative numbers work.