Reputation: 1936
I am getting two vastly different answers with regards to simple matrix norms when comparing the MATLAB and Python functions.
Let
R =
0.9940 0.0773 -0.0773
-0.0713 0.9945 0.0769
0.0828 -0.0709 0.9940
Then in MATLAB:
>> norm(R)
ans =
1
But in Python
from scipy.linalg import norm
import numpy as np
print norm(R),np.linalg.norm(R)
1.73205080757 1.73205080757
where
print scipy.__version__,np.__version__
0.14.0 1.9.0
How did I manage to so comprehensively screw that up?
Upvotes: 4
Views: 6172
Reputation: 109
Matlab default for matrix norm is the 2-norm while scipy and numpy's default to the Frobenius norm for matrices. Specifying the norm explicitly should fix it for you
Upvotes: 2
Reputation: 124563
Either do this in MATLAB:
>> norm(R,'fro')
or this in Python:
>>> np.linalg.norm(R,2)
Upvotes: 7