clear all, close all, clc


p = 10;                              % number of terms in the model
x = linspace(0,4,100)';              % number of observations
f = x.^2 + 2*randn(100,1);           % observations

A = zeros(100,p);
for j=1:p
    A(:,j) = x.^(j-1);
end


xL2 = pinv(A)*f;

[XL1 FitInfo] = lasso(A,f,'CV',10);
lassoPlot(XL1,FitInfo,'PlotType','CV')
%lassoPlot(XL1,FitInfo,'PlotType','Lambda')

xL1 = XL1(:,FitInfo.Index1SE);
xL1DeBiased = pinv(A(:,abs(xL1)>0))*f;



%%

%figure(1)
%set(gcf,'Position',[100 100 600 400])
%set(gcf,'PaperPositionMode','auto')
%print('-depsc2', '-loose', '../figures/f_chCS_ex07_lassoA');

%figure(2)
%set(gcf,'Position',[100 100 600 400])
%set(gcf,'PaperPositionMode','auto')
%print('-depsc2', '-loose', '../figures/f_chCS_ex07_lassoB');
