The question is, I know you are singular, but just HOW singular are you? ;-) It seems to me there are several questions of interest.
- Is A numerically singular at all? Cond gives us a measure of that.
- What is the rank of the null space? Null gives us an opinion about that, but not a metric.
A measure of how close to entrance into the null space is to consider the tolerance that null would use. That depends on the largest singular value. Any singular value that lies below some fraction of the largest singular value, results in the corresponding singular vector getting dumped into the null space.
tol = max(m,n) * eps(max(S));
So I would look at the smallest singular value that lies above that tolerance. Then compute something like this:
So how close is that value to the tolerance for entrance into the null space?
Note that this applies to a matrix that is numerically full rank too. For example...
A = vander(1:10);
[m,n] = size(A);
tol = max(m,n) * eps(max(S))
tol =
2.38418579101562e-06
min(S(S > tol))/tol
ans =
216.509958943425
So A is close to singular, but not there yet.
But if I push things a bit harder...
A = vander(1:15);
[m,n] = size(A);
S = svd(A)
S =
3.15839869049552e+16
66664300967337.7
322942655858.374
2723747542.51185
36045801.6655343
713911.28106567
20777.0142721889
891.531934617208
58.0952625517871
6.2867119286002
1.42076230762098
0.36061079623119
0.0322030740265822
0.00106225764978576
1.22304251430976e-05
tol = max(m,n) * eps(max(S))
tol =
60
So it looks like 7 singular values fall below tol. Easy to compute the rank of the null space.
And the next one is not that far behind.
min(S(S > tol))/tol
ans =
14.8588655769535
Or, perhaps report it in terms of the log10 of that, which gives the answer in terms of how many powers of 10 does it lie above the tolerance.
log10(min(S(S > tol))/tol)
ans =
1.17198565380708
Another one. I recall that magic squares (as produced by magic, for order > 2) are singular for even order.
A = magic(4);
[m,n] = size(A);
S = svd(A)
S =
34
17.8885438199983
4.47213595499958
4.17280694870505e-16
tol = max(m,n) * eps(max(S))
tol =
2.8421709430404e-14
min(S(S > tol))/tol
ans =
1.5735e+14
So the rank of the null space was 1, but the next singular value is nowhere close to that tolerance.
So I'd think you need to report two measures.
1. How many singular values fall below tol?
2. How close is the next one to tolerance failure?
Best Answer