Syntax:
fit {range} <function> '<datafile>' {datafile-modifiers} \ via {'<parameter file>' | <var1>,<var2>,...}
Notice that via is now a required keyword, to distinguish it from a scanf format string.
{[range]} is [ {variable=} { <min> } { :<max> } ], allowing the range of the fit to be limited temporarily in a manner analogous to plot. <function> is any valid gnuplot expression, although it is usual to use a previously user-defined function of the form f(x). <datafile> is treated as in the plot command. All the modifiers for datafiles (using, every,...) in plot are available here—see plot datafile for full details. The default column for x is 1 for y is 2. They may be changed by the using x:y mechanism. If a third column or expression is specified with using, uncertainties are read for each y value, to be used as weights during the fit. Otherwise all data are weighted equally. The start parameters may be specified in a (load-) file wherein each line is of the form:
varname = value
Comments, marked by '#', and blank lines are permissible. The form
varname = value # FIXED
means that the variable is treated as a fixed parameter that is initialized but will not be adjusted. It is not necessary (but sometimes useful for clarity) to specify them at all. The keyword '# FIXED' has to appear in exactly this form.
The other means of specifying the adjustable parameters is to provide a comma-separated list of variable names after the via keyword. If any of these variables do not yet exist within the current gnuplot session, they are created with an initial value of 1.0, but the fit is more likely to converge if a more appropriate starting value is given. If this form is used, it may prove beneficial to iterate the fit, allowing only one or two variables to be adjusted at a time until a reasonably close fit is obtained, before allowing fit to vary all parameters.
After each iteration step, detailed information is given about the fit's state, both on the screen and on a logfile ``fit.log''. This file will never be erased but always appended to so that the fit's history isn't lost. After each iteration step, the fit may be interrupted by pressing Ctrl-C (any key BUT Ctrl-C under MSDOS and Atari Multitasking Systems). Then you have the options of stopping (and accepting the current parameter values), continuing the iteration of the fit, or executing a gnuplot command specified by an environment variable FIT_SCRIPT. A plot or load command may be useful in this context.
Special gnuplot variables:
FIT_INDEX contains the current data point number during execution, starting with 1. You may use it in your fit function to implement multiple-branch fits. FIT_LIMIT may be specified to change the default epsilon limit (1e-5). When the sum of squared residuals changes between two iteration steps by less than a factor of this number, the fit is considered to have 'converged'.
(FIT_SKIP was available in previous released of gnufit. Its functionality is now obtained using the every modifier for datafiles.)
Environment variables:
FIT_LOG changes the logfile's path from './fit.log' (write permission is necessary). FIT_SCRIPT specifies a command to be executed after an user interrupt.
Examples:
f(x) = a*x**2 + b*x + c fit f(x) 'measured.dat' via 'start.par' fit f(x) 'measured.dat' using 3:($7-5) via 'start.par' fit f(x) './data/trash.dat' using 1:2:3 via a, b, c
SEE ALSO: update