I am new to Numpy. I couldn't understand the use of ord=2 in numpy.linalg.norm. For example, what is the difference between:
np.linalg.norm(np.array([[-4, -3, -2],
[-1, 0, 1],
[ 2, 3, 4]]))
and
np.linalg.norm(np.array([[-4, -3, -2],
[-1, 0, 1],
[ 2, 3, 4]]),2)
In Numpy documentation, it is given that ord =2 means 2-norm (largest sing. value). I couldn't understand what is meant by largest singular value. Could you explain?
They are referring to the so called operator norm. Your operand is 2D and interpreted as the matrix representation of a linear operator. The operator norm tells you how much longer a vector can become when the operator is applied. The 2 refers to the underlying vector norm. The singular value definition happens to be equivalent.
As for the difference, the default is not the operator norm but the Frobenius norm which is the Euclidean norm if you interpret the matrix as a vector in nxm - space. Looking at examples (the easiest being the identity matrix) it is clear that the Frobenius and operator norms are different.
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