lsqnon - take larger steps
11 ビュー (過去 30 日間)
I'm trying to use lsqnonlin to minimize the difference between the output of a model and experiments, in order to determine the best set of three parameters to use in the model. The problem is, whatever the initial point, lsqnonlin always converges in a few iteration, but it does not really moves from the initial point. I have investigated the solution field, and I see there is a clear minimum. I have played around with TolX and TolFun, but with no success. The parameters are in the order of magnitude of 1. If a record the parameters searched by lsqnonlin, it moves from the initial point by 1e-6 or even lower steps, and this is by far too strict for the solution I require. Is there a way to increase this step to 1e-2 or 1e-1?
Would other function better suit this problem (e.g. fminunc)?
thanks in advance Mauri
I tried to make it easier. I fix all the parameters except for one to reasonable values, I apply a brute force method (I pick up 4 values of the parameters under fitting), and I see a minimum. Now, if I give lsqnon the worst initial point between those I investigated, it does not move toward the best value, it just does not move from there.
What could it be?
回答 (5 件)
Gabo 2011 年 6 月 8 日
It would be useful to see some code. From the description, though, you might be passing the wrong function to lsqnonlin.
Say the parameters you are fitting are a vector a, and your errors are err(a) = (err1(a),...,errN(a)). It seems that you are passing f(a) = err1(a)^2+...+errN(a)^2 to lsqnonlin. That would be incorrect. You need to pass err(a) to lsqnonlin, which internally squares the errors and adds them up. See the "Description" in the lsqnonlin help.
Alternatively, you can use fminunc, as you pointed out, which, indeed, takes f(a) as input.
I see you were passing the right function. From your code, the only suspicious point is the last line of mySimulat. Is diffe a 50 by 1 vector or is it larger? The issue is, if diffe has more than 50 entries, diff also has more than 50 entries, and entries 51:end won't change. What happens if you set diff=Yexp-Ysim directly?
You can also try fminunc (as you mentioned before), to compare.
Maurizio, unfortunately, it's not possible to force the algorithm to take a step of a minimum length --by design, the algorithm computes the step taking many things into consideration.
There could be something special about that point, or about the sensitivity of the simulation values to small changes around that point. Regarding the former, you can try different starting points. Regarding the latter, you may try changing the parameters that control the finite difference derivative estimation internally. For example, if the simulation is barely sensitive to small changes in the parameters, but it changes more noticeably for larger changes in the parameters, you can reset the DiffMinChange option to something like 1e-2, or 1e-4.