0
import numpy as np
X = np.random.rand(4,3)
print("X: \n", X)
XMin = np.zeros((1,3), dtype=np.float64)
for j in range(3):
print("X[{0}]: {1}".format(j,X[j]))
minimo = np.amin(X[j])
print("minimo: ", minimo)
np.append(XMin, minimo, axis=1)
print("XMin: \n", XMin)
I tried to find the minimum value of each column and make Xmin get the minimum values, as in the example below, but could not:
X:[[3.83537931e-01 3.14643360e-02 6.56821484e-04]
[4.99427675e-01 3.68729746e-01 5.12404699e-01]
[8.79530786e-01 4.91253677e-01 9.46192774e-01]
[7.94819914e-01 2.00760544e-01 5.53820343e-01]]
XMin:[[3.83537931e-01 2.00760544e-01 5.12404699e-01]]
Using
a.min(axis=1)
you are picking up the minimum of each line. If you useaxis=0
, will take the minimum of each column, which will be[1 2 3]
.– klaus
Really, I messed up, I’ll edit.
– Sidon