Matrix Completion.m

From Wikimization

(Difference between revisions)
Jump to: navigation, search
(New page: == Matlab demonstration of the paper by Cai, Candès, & Shen, [http://arxiv.org/abs/0810.3286 A Singular Value Thresholding Algorithm for Matrix Completion, 2008]== <pre> %% Set path and g...)
Line 1: Line 1:
-
== Matlab demonstration of the paper by Cai, Candès, & Shen, [http://arxiv.org/abs/0810.3286 A Singular Value Thresholding Algorithm for Matrix Completion, 2008]==
+
== Matlab demonstration of Cai, Candès, & Shen ==
 +
[http://arxiv.org/abs/0810.3286 A Singular Value Thresholding Algorithm for Matrix Completion, 2008]
<pre>
<pre>
%% Set path and global variables
%% Set path and global variables

Revision as of 17:42, 15 February 2009

Matlab demonstration of Cai, Candès, & Shen

A Singular Value Thresholding Algorithm for Matrix Completion, 2008

%% Set path and global variables
    global SRB 
    SRB = true;
  
%% Setup a matrix
randn('state',2008);
rand('state',2008);

n = 1000; r = 10;
M = randn(n,r)*randn(r,n);

df = r*(2*n-r);
oversampling = 5;  m = 5*df; 

Omega = randsample(n^2,m); 
data = M(Omega);

%% Set parameters and solve

p  = m/n^2;  delta = 1.2/p;      
maxiter = 500;
tol = 1e-4;

%% Approximate minimum nuclear norm solution by SVT algorithm

    tic
    [U,S,V,numiter] = SVT(n,Omega,data,delta,maxiter,tol);
    toc 
    
%% Show results

 X = U*S*V';

disp(sprintf('The relative error on Omega is: %d ', norm(data-X(Omega))/norm(data)))
disp(sprintf('The relative recovery error is: %d ', norm(M-X,'fro')/norm(M,'fro')))
disp(sprintf('The relative recovery in the spectral norm is: %d ', norm(M-X)/norm(M)))