Iterative shrinkage algorithm for L1 optimization - A MATLAB Code testing

29 Views Asked by At

I am going to solve the problem:

$x =: \underset{x}{\text{argmin }}\frac{1}{2}||y-Ax||^2+||x||_1$

using iterative shrinkage algorithms (ISTA). There is a modified version know as FISTA which is as follows:

enter image description here

In order to see that I understand it, I wrote a MATLAB code to test if I am able to recover my sparse model, $x$ as in $Ax=y$. My code is as follows:

xorig = zeros(100,1);
xorig (5:15:end) = 10;
figure, plot(xorig)
A = magic(100)/10000;
figure, imagesc(A)
b = A*xorig;
xnoisy = xorig + randn(size(xorig));
x0 = xnoisy;

%---------------------------
tk = 1;
thrsh = 0.001;
landa = 2.5;
yk = x0;

for iter = 1:1000
  
     xk = wthresh(yk-landa*A'*(A*yk-b),'s',thrsh);
   
     tkk = (1+sqrt(1+4*tk^2))/2;
     ak = (tk-1)/tkk;
     ykk = xk+ak*(xk-x0);

     tk = tkk;
     yk = ykk; 
     x0 = xk;
end

My first question is that am I written the code right? And if yes, why I can not recover proper $x$ ? (I have tested different values for step size (landa) and thresholding for shrinkage operator)

Second question is that is there any better way to choose parameters instead of testing for different values?