4
$\begingroup$

I have a matrix A which is an approximation to the known matrix B. Both matrices are square, 3x3 matrices and, in this case, are symmetric. Is there a 'best' method for calculating percent error in the approximation? I had been using the sum the 'sum of squares' error for all entries divided by the sum of 'sum of squares' of the true matrix, pct_err = sum(sum( (A-B).^2 ))/(sum(sum(B.^2)) and realized that this is simply the square of norm(A-B,2)/norm(B,2) which gives drastically different percent error estimates.

How should I go about calculating percent error between two matrices, or maybe more generally, two tensors?

EDIT: Thanks to some of the comments, I now recognize the difference between the 2-norm and the Frobenius norm. In either case, however, the type of norm I am taking is of relatively small consequence. The bigger question is how to represent the percent error of a 2nd rank tensor correctly.

$\endgroup$
  • $\begingroup$ There is no "correct" way. You have to pick your favorite measure of beauty and use that. $\endgroup$ – Bill Barth Jul 28 '13 at 13:03
1
$\begingroup$

norm(A,2) returns the largest singular value of A not the square root of the sum of squares of its elements.

$\endgroup$
  • $\begingroup$ Sorry, but could you explain that a bit more? The definition of the matrix p-norm (en.wikipedia.org/wiki/Matrix_norm) is not the largest singular value. When I wrote norm(A,2) I was speaking about the 2-norm, even though I was using MATLAB's syntax. Even in MATLAB, however, it appears, that norm(A,2) is still using the 2-norm (mathworks.com/help/matlab/ref/norm.html). $\endgroup$ – drjrm3 Jul 26 '13 at 20:35
  • $\begingroup$ I will add that I see that the largest singular value returns the same as the norm(A,2) command in MATLAB, but sum(sum( A.^2 ))^0.5 returns something very close. Could you possibly explain the difference and why they are so similar? $\endgroup$ – drjrm3 Jul 26 '13 at 20:38
  • $\begingroup$ The 2-norm of a matrix is not the square root of the sum of the squares of its elements, it's defined as $max\{\|Ax\|_2 : \|x\|_2 = 1\} $, which is the same as the largest singular value. You can see a simple difference by comparing the sum of squares for a matrix with only ones on the diagonal. The MATLAB norm(A,2) returns 1, and the square root of the sum of the squares returns sqrt(1/n) where n is the dimension of the matrix. $\endgroup$ – Bill Barth Jul 26 '13 at 21:25
1
$\begingroup$

It appears that what you want in MATLAB is norm(A, 'fro'), the Frobenius norm.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.