Gnuplot's fit command is fairly robust, but when asked to fit with parameters that differ in size by many orders of magnitude, the fit command fails.
While it's easy enough rescale a function so that the parameters are of similar magnitude, it isn't always obvious that this is necessary. But this can be done internally to the fit command.
I've attached a patch that touches 7 lines and adds 13 more to fit.c that does this. I've tested this on some data sets where the scaling problem arises, and also on the fits in fit.dem. If reasonable initial guesses are provided, the fits often (but not always) seem to converge in fewer iterations.
michal
2010-11-09
patch to prescale fit parameters, against 4.4.2
Bastian Märkisch
2012-05-20
Update to current CVS; Preserve sign of parameters; Fix error variables
Bastian Märkisch
2012-05-20
Update of this patch to current CVS 4.7.
Additionally, preserve the sign of the fit parameters. That way, we still obtain the correct correlation matrix. Also scale the parameter error saved to variables.
michal
2013-03-11
Update of this patch (against 4.6.1). corrected comment describing behaviour with initial parameter value of 0, made prescaling an option with set fit [no]prescale, also
updated show fit, unset fit, and documentation.
michal
2013-03-11
update as above, but against cvs.
michal
2013-03-12
This version includes update to 'save' so prescale preference is remembered. Against 4.6.1.
michal
2013-03-12
and against current CVS
Ethan Merritt
2013-03-12
If I run "fit.dem" with and without prescaling enabled, one of the demos reports drastically different values in the parameter correlation matrix. (Note that the demo script must be edited to set prescaling after each "reset" command). Since correlation should not depend on scaling, I worry that this indicates an error. Comments?
Ethan Merritt
2013-03-12
Never mind. I now see that the problem case is the one where without prescaling the fit is stopped after 50 iterations for non-convergence. Removing the iteration limit produces results more in line with the prescaling run. So that's actually a demo of the better convergence with prescaling :-)
Ethan Merritt
2014-02-17