I want to approximate a constant function with a sum of nonlinear functions. I can do this with ordinary least squares, but with lasso something is going wrong, probably because the function to be approximated is constant. I give a toy example in Matlab below:
t = -1:0.01:1; %horizontal axis
x = [exp(-(t+0.5).^2); exp(-t.^2); exp(-(t-0.5).^2);]'; %I use radial basis functions in this example
y = 0.7 * ones(201,1); %Approximate a constant function by a weighted sum of radial basis functions
w = y'/x'; %ordinary least squares works fine
plot(t,w*x'); hold on; plot(t,y,'--k'); axis([-1,1,0,1]); %show results
b = lasso(x,y); %lasso does not work, this gives only zeros
w = b(:,1); %zero weights
plot(t,w*x'); hold on; plot(t,y,'--k'); axis([-1,1,0,1]); %show results
I noticed Lasso subtracts the mean from the input and output first, so this would give a zero output, hence all the zero weights resulting from lasso. Is there any way to circumvent this? Or another way to get a sparse result for the weights?