I have a Matlab function that runs a SVD. Unfortunately, the function [U,S,V] = svd(A)
has a sign ambiguity which could give misleading results in my application. The function [sgns,loads] = sign_flip(loads,X)
published on Matlab Central File Exchange [1] should solve this problem. There is also a paper on this impelentation [2]. The function computes a sign matrix and sign-corrected singular vectors. In the paper, the methodology is described by:
"In order to identify the sign of a singular vector, it is suggested that it be similar to the sign of the majority of vectors it is representing. Geometrically, it should point in the same, not the opposite, direction as the points it is representing."
Now, what happens, if I have a singular matrix? When I apply sign_flip
on a singular matrix, it gives an invalid sign matrix:
X = [1, 0; 0, 0];
[U, S, V] = svd(X);
sign_flip({U * S, V}, X)
ans =
1 NaN
1 0
The NaN is produced in line 30, a = a/(a'*a);
. Is anyone familiar with this function? Is this an intended behavior? I am asking here, because the last comment on Matlab Central File Exchange is from 2010.
[1] http://de.mathworks.com/matlabcentral/fileexchange/22118-sign-correction-in-svd-and-pca
[2] http://prod.sandia.gov/techlib/access-control.cgi/2007/076422.pdf