What's the truncation error in SVD?

8 次查看(过去 30 天)
Hi all,
I'm trying to prove one thing: perform SVD on matrix a, the truncation error of singular values equals to truncation error of products of singular vectors. Here is the code:
clear; clc;
% PART 1.
% define the matrix a.
a = magic(8);
% define number of singular values left after truncation.
n = 2;
[u, s, v] = svd(a, 0);
% sum all singular values.
ds = diag(s);
dss = sum(ds);
% sum first n singular values
dssn = sum(ds(1:n));
% work out the error after truncation.
dsp = 1 - dssn / dss;
% PART 2
% multiply left singular vectors with singular values
u = u * s;
% select the first n singular vectors, i.e. to truncate
us = u(:, 1:n);
vs = v(:, 1:n);
% reconstruct the solution
ur = us * vs';
% work out the error
up = norm(ur - a, 'fro') / norm(a, 'fro');
I expect dsp = up, but dsp = 0.0431, up = 0.0613, why?

回答(1 个)

Christine Tobler
Christine Tobler 2017-8-30
编辑:Christine Tobler 2017-8-30
Use dsp = norm(ds(n+1:end)) / norm(ds) instead of the sum.
This is because in norm(U*S*V', 'fro'), you can move U and V outside of the norm since they are orthogonal, leaving you with norm(S, 'fro'), and since S is diagonal, this is equal to norm(diag(S)).

类别

Help CenterFile Exchange 中查找有关 Operating on Diagonal Matrices 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by