How do I perform a truncated SVD on a matrix?
53 views (last 30 days)
Show older comments
David Haydock
on 14 Aug 2020
Commented: David Haydock
on 16 Aug 2020
Title says it all. I have an input matrix that I need to generate a truncated SVD for, so that I can calculate the SVD's reconstruction error. I know that svd is a function, but I can't find any functions anywhere that work specifically for a truncated SVD.
0 Comments
Accepted Answer
Bjorn Gustavsson
on 14 Aug 2020
Simply use the standard svd-function, then you can simply calculate the reconstruction-error at different truncation-levels by setting the eigenvalues outside of your trunkation to zero (that is what you do when trunkating, well close enough. If you want you can simply trunkate the U, S and V matrices too, but this way you cut out all thinking). Something like this:
Im = imread('cameraman.tif');
[U,S,V] = svd(double(Im));
subplot(1,3,1),imagesc(Im)
lambda = diag(S);
l50 = lambda;
l50(51:end) = 0;
subplot(1,3,2)
imagesc(U*diag(l50)*V')
subplot(1,3,3)
imagesc(double(Im)-U*diag(l50)*V')
HTH
5 Comments
Bjorn Gustavsson
on 16 Aug 2020
For initial overview-reading I typically recommend wikipedia (SVD low-rank approximation) for getting the very first overview. Then you can branch out in your desired directions - I mainly use SVD for inverse-problems, your needs might take you in other directions.
Then, the truncated SVD is the "best lower-rank approximation" (minimum Frobenius-norm) of your original matrix. As for how that relates to conditional average is not clear to me. I've only ever encountered conditional averaging in the context of averaging time-serieses syncronized relative to some triggering event (that might occur at "random" instanses in time). To me that seems to be something completely different than a truncated SVD-approximation. I suggest going back to whomever told you this and ask for a more detailed explanation...
More Answers (0)
See Also
Categories
Find more on Linear Algebra in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!