MATLAB: ‘lsqnonlin’ giving non-identical results from multiple trials considering same data and starting parameter values

independent trialslsqnonlinnon-identical resultssame datasame parameter starting values

Hi
I implemented lsqnonlin for estimating 30 parameters in my Model. My objective function is of the order 18000X22.
My lsqnonlin settings are:
1. I have parameter bounds set
2. I use trust-region-reflective algorithm.
Strangely, I get non-identical values of estimates for the 30 parameters under consideration with multiple trials using the same code, data going into lsqnonlin for estimation and with same starting values.
As far as I know, lsqnonlin is a deterministic optimization algorithm . So, I am supposed to get identical results from these trials.
Any inputs would be helpful in understanding this variability in results from independent estimation trials. using same data and parameter starting values.
Thanks for your time

Best Answer

lsqnonlin is indeed a deterministic solver. If you have the same data in, then you should get the same iterative steps. Since you don't, then there is likely something nondeterministic in your objective function.
Try an experiment. Execute the line
rng default
immediately before running lsqnonlin. Then execute the line and lsqnonlin again. I would be surprised if there is any difference between the two runs, unless your objective function calls an external piece of code that keeps its own state.
Alan Weiss
MATLAB mathematical toolbox documentation
Related Question