[Numpy-discussion] matrix norm

Warren Weckesser warren.weckesser at enthought.com
Mon Oct 22 12:09:24 EDT 2012


On Mon, Oct 22, 2012 at 10:56 AM, Charles R Harris <
charlesr.harris at gmail.com> wrote:

>
>
> On Mon, Oct 22, 2012 at 9:44 AM, Jason Grout <jason-sage at creativetrax.com>wrote:
>
>> I'm curious why scipy/numpy defaults to calculating the Frobenius norm
>> for matrices [1], when Matlab, Octave, and Mathematica all default to
>> calculating the induced 2-norm [2].  Is it solely because the Frobenius
>> norm is easier to calculate, or is there some other good mathematical
>> reason for doing things differently?
>>
>>
> Looks to me like Matlab, Octave, and Mathematica all default to the
> Frobenius norm .
>


Not octave:

octave-3.4.0:26> a = [1 2; 3 4]
a =

   1   2
   3   4


The default norm (for a 2x2 matrix) is the spectral norm:

octave-3.4.0:27> norm(a)
ans =  5.4650
octave-3.4.0:28> norm(a, 2)
ans =  5.4650
octave-3.4.0:29> svd(a)(1)
ans =  5.4650

not the Frobenius norm:

octave-3.4.0:30> norm(a, 'fro')
ans =  5.4772
octave-3.4.0:31> sqrt(sum(sum(a.**2)))
ans =  5.4772


Warren



> Chuck
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20121022/7da7ca0a/attachment.html>


More information about the NumPy-Discussion mailing list