fit using lsqcurvefit

半世苍凉 提交于 2019-12-04 14:03:31

As you suggested, you're going to run into numerical issues whenever you have parameters that vary over 28 (!) orders of magnitude. LSQCURVEFIT, for example, will try and estimate proper gradient steps, and those calculations may be sensitive to numerical stability (depending on the actual implementation - see http://en.wikipedia.org/wiki/Levenberg%E2%80%93Marquardt_algorithm for a summary of how all this is done).

In my experience, you need to find a way to normalize the input parameters that make them more comparable. For example, you can take the log of all the values, and then exp() them inside you're objective function.

params = log([4.475e14;0.4e14;1.8e-14])

and

function [ value ] = lorentz( x,x0,gamma,amp )
    gamma = exp(gamma); 
    amp = exp(amp);
    x0 = exp(x0);
    value = amp * gamma^2 ./ ((x-x0).^2 + gamma^2);
end

That may introduce other instabilities, but it should get you started.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!