comparison matlab/RecomTST/RecommendedTST.m @ 4:4393ad5bffc1

Implemented the RecommendedTST algorithm Test file written, but test not yet working.
author nikcleju
date Mon, 24 Oct 2011 23:39:53 +0000
parents
children
comparison
equal deleted inserted replaced
3:537f7798e186 4:4393ad5bffc1
1 function beta = RecommendedTST(X,Y, nsweep,tol,xinitial,ro)
2
3 % function beta=RecommendedTST(X,y, nsweep,tol,xinitial,ro)
4 % This function gets the measurement matrix and the measurements and
5 % the number of runs and applies the TST algorithm with optimally tuned parameters
6 % to the problem. For more information you may refer to the paper,
7 % "Optimally tuned iterative reconstruction algorithms for compressed
8 % sensing," by Arian Maleki and David L. Donoho.
9 % X : Measurement matrix; We assume that all the columns have
10 % almost equal $\ell_2$ norms. The tunning has been done on
11 % matrices with unit column norm.
12 % y : output vector
13 % nsweep : number of iterations. The default value is 300.
14 % tol : if the relative prediction error i.e. ||Y-Ax||_2/ ||Y||_2 <
15 % tol the algorithm will stop. If not provided the default
16 % value is zero and tha algorithm will run for nsweep
17 % iterations. The Default value is 0.00001.
18 % xinitial : This is an optional parameter. It will be used as an
19 % initialization of the algorithm. All the results mentioned
20 % in the paper have used initialization at the zero vector
21 % which is our default value. For default value you can enter
22 % 0 here.
23 % ro : This is a again an optional parameter. If not given the
24 % algorithm will use the default optimal values. It specifies
25 % the sparsity level. For the default value you may also used if
26 % rostar=0;
27 %
28 % Outputs:
29 % beta : the estimated coeffs.
30 %
31 % References:
32 % For more information about this algorithm and to find the papers about
33 % related algorithms like CoSaMP and SP please refer to the paper mentioned
34 % above and the references of that paper.
35
36
37 colnorm=mean((sum(X.^2)).^(.5));
38 X=X./colnorm;
39 Y=Y./colnorm;
40 [n,p]=size(X);
41 delta=n/p;
42 if nargin<3
43 nsweep=300;
44 end
45 if nargin<4
46 tol=0.00001;
47 end
48 if nargin<5 | xinitial==0
49 xinitial = zeros(p,1);
50 end
51 if nargin<6 | ro==0
52 ro=0.044417*delta^2+ 0.34142*delta+0.14844;
53 end
54
55
56 k1=floor(ro*n);
57 k2=floor(ro*n);
58
59
60 %initialization
61 x1=xinitial;
62 I=[];
63
64 for sweep=1:nsweep
65 r=Y-X*x1;
66 c=X'*r;
67 [csort, i_csort]=sort(abs(c));
68 I=union(I,i_csort(end-k2+1:end));
69 xt = X(:,I) \ Y;
70 [xtsort, i_xtsort]=sort(abs(xt));
71
72 J=I(i_xtsort(end-k1+1:end));
73 x1=zeros(p,1);
74 x1(J)=xt(i_xtsort(end-k1+1:end));
75 I=J;
76 if norm(Y-X*x1)/norm(Y)<tol
77 break
78 end
79
80 end
81
82 beta=x1;