MATLAB: svds() not converging

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2012-09-14T02:30:10Z Indexed on 2012/09/14 21:38 UTC
Read the original article Hit count: 204

Filed under:
|
|

So using MATLAB's svds() function on some input data as such:

[U, S, V, flag] = svds(data, nSVDs, 'L')

I noticed that from run to run with the same data, I'd get drastically different output SVD sizes from run to run. When I checked whether 'flag' was set, I found that it was, indicating that the SVDs had not converged. My normal system here would be that if it really needs to converge, I'd do something like this:

flag = 1
svdOpts = struct('tol', 1e-10, 'maxit', 600, 'disp', 0);
while flag:
    if svdOpts.maxit > 1e6
        error('There''s a real problem here.')
    end

    [U, S, V, flag] = svds(data, nSVDs, 'L', svdOpts)
    svdOpts.maxit = svdOpts.maxit*2
end

But from what I can tell, when you use 'L' as the third argument, the fourth argument is ignored, meaning I just have to deal with the fact that it's not converging? I'm not even really sure how to use the 'sigma' argument in place of the 'L' argument. I've also tried reducing the number of SVDs calculated to no avail. Any help on this matter would be much appreciated.

EDIT While following up on the comments below, I found that the problem had to do with the way I was building my data matrices. Turned out I had accidentally inverted a matrix and had an input of size (4000x1) rather than (20x200), which was what was refusing to converge.

I also did some more timing tets and found that the fourth argument was not, in fact, being ignored, so that's on me.

Thanks for the help guys.

© Stack Overflow or respective owner

Related posts about matlab

Related posts about octave