fminsearch: improving optimization of parameters over wide scale of y values

조회 수: 9 (최근 30일)
Hello,
I am currently trying to solve the problem of fitting a known function to a given dataset of x, y, with y spanning a high range of values. Here's the snippet of code that needs consideration:
fit_params0= [35 1.11 1.7 RL0array(i_temp)];
LB=[10 0.1 0.1 1000];
UP=[1e+6 2 10 1e+12];
fun=@(fit_params) norm (abs( ( A_const.*T(i_temp).*T(i_temp).*exp( -q_electron.*fit_params(2)./(k.*T(i_temp)) ).*S ).*( exp( q_electron.*(tempU2-tempI2.*fit_params(1))./( fit_params(3).*k.*T(i_temp) )) -1 ) ) + tempU2./fit_params(4) - tempI2 );
fit_params=fminsearchbnd(fun,fit_params0, LB, UP, options);
x is tempU2 and y is tempI2.
fminsearchbnd is a modified version of fminsearch that enforces upper and lower bounds of variation parameters. fun calculates the absolute difference between the fitted y data and the given y data tempI2, takes the absolute values, then uses norm() to get a scalar from the resultant matrix.
Attached is a plot of the given data (blue line) compared to the plot of the fitted equation (blue dots):
Note that this is a logy graph. As you can see, the fit works great for high values of y... However, my y data ranges from 1E-3 to values as low as 1E-12.
My question, then, is how would I go about making fun() sensitive to scale after the difference between fitted y and given y is calculated? I do not want fminsearch to waste time looking at too many significant digits on high y scales.
I imagine something like multiplying matrix elements by their own scale during a second iteration of fminsearch would mitigate this problem? By that I mean, for example, if some calculated fun value would be 3.5E-5, it would then be multiplied by its own scale (E-5), to result in 3.5, giving the optimization problem equal weight on all scales.

채택된 답변

John D'Errico
John D'Errico 2019년 8월 4일
편집: John D'Errico 2019년 8월 4일
This is not a question of the optimizer you use. It is a question of scale, and your objective function. ANY optimizer will fail, when posed the problem that you have posed.
But what did you do? You plotted it on a LOG scale axis!!!!!! What does that tell you? It tells you that you want to LOG your data. Log your model. Now minimize the differences of those logs.
By logging the process, this automatically allows it to work on data that varies over large scale differences. Logs turn the problem into a proportional error problem.
  댓글 수: 1
Edvinas Gvozdiovas
Edvinas Gvozdiovas 2019년 8월 4일
편집: Edvinas Gvozdiovas 2019년 8월 4일
I hope this post won't be a highlight of some 'top epic matlab central fails 2019' youtube video. Thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Nonlinear Optimization에 대해 자세히 알아보기

제품


릴리스

R2016b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by