我想用非线性函数的总和来近似一个常数函数。我可以用普通的最小二乘来做到这一点,但是用套索会出错,可能是因为要逼近的函数是常数。我在下面的 Matlab 中给出了一个玩具示例:
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
我注意到套索首先从输入和输出中减去平均值,所以这将给出零输出,因此所有零权重都是由套索产生的。有什么办法可以规避这种情况吗?或者另一种方法来获得权重的稀疏结果?