#507 Prescale fit parameters (patch attached)

None
closed-accepted
nobody
fit (9)
7
2014-03-04
2010-11-09
michal
No

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.

Discussion

1 2 3 > >> (Page 1 of 3)
  • michal
    michal
    2010-11-09

    patch to prescale fit parameters, against 4.4.2

     
    Attachments
  • Update to current CVS; Preserve sign of parameters; Fix error variables

     
  • 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
    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
    michal
    2013-03-11

    update as above, but against cvs.

     
  • michal
    michal
    2013-03-12

    This version includes update to 'save' so prescale preference is remembered. Against 4.6.1.

     
  • michal
    michal
    2013-03-12

    and against current CVS

     
  • Ethan Merritt
    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
    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
    Ethan Merritt
    2014-02-17

    • Group: -->
    • Priority: 5 --> 7
     
1 2 3 > >> (Page 1 of 3)