Credits | Overview | Plotting Styles | Commands | Terminals |
---|
The set fit command controls the options for the fit command.
Syntax:
set fit {nolog | logfile {"<filename>"|default}} {{no}quiet|results|brief|verbose} {{no}errorvariables} {{no}covariancevariables} {{no}errorscaling} {{no}prescale} {maxiter <value>|default} {limit <epsilon>|default} {limit_abs <epsilon_abs>} {start-lambda <value>|default} {lambda-factor <value>|default} {script {"<command>"|default}} {v4 | v5} unset fit show fit
The logfile option defines where the fit command writes its output. The <filename> argument must be enclosed in single or double quotes. If no filename is given or unset fit is used the log file is reset to its default value "fit.log" or the value of the environmental variable FIT_LOG. If the given logfile name ends with a / or \, it is interpreted to be a directory name, and the actual filename will be "fit.log" in that directory.
By default the information written to the log file is also echoed to the terminal session. set fit quiet turns off the echo, whereas results prints only final results. brief gives one line summaries for every iteration of the fit in addition. verbose yields detailed iteration reports as in version 4.
If the errorvariables option is turned on, the error of each fitted parameter computed by fit will be copied to a user-defined variable whose name is formed by appending "_err" to the name of the parameter itself. This is useful mainly to put the parameter and its error onto a plot of the data and the fitted function, for reference, as in:
set fit errorvariables fit f(x) 'datafile' using 1:2 via a, b print "error of a is:", a_err set label 1 sprintf("a=%6.2f +/- %6.2f", a, a_err) plot 'datafile' using 1:2, f(x)
If the errorscaling option is specified, which is the default, the calculated parameter errors are scaled with the reduced chi square. This is equivalent to providing data errors equal to the calculated standard deviation of the fit (FIT_STDFIT) resulting in a reduced chi square of one. With the noerrorscaling option the estimated errors are the unscaled standard deviations of the fit parameters. If no weights are specified for the data, parameter errors are always scaled.
If the prescale option is turned on, parameters are prescaled by their initial values before being passed to the Marquardt-Levenberg routine. This helps tremendously if there are parameters that differ in size by many orders of magnitude. Fit parameters with an initial value of exactly zero are never prescaled.
The maximum number of iterations may be limited with the maxiter option. A value of 0 or default means that there is no limit.
The limit option can be used to change the default epsilon limit (1e-5) to detect convergence. When the sum of squared residuals changes by a factor less than this number (epsilon), the fit is considered to have 'converged'. The limit_abs option imposes an additional absolute limit in the change of the sum of squared residuals and defaults to zero.
If you need even more control about the algorithm, and know the Marquardt-Levenberg algorithm well, the following options can be used to influence it. The startup value of lambda is normally calculated automatically from the ML-matrix, but if you want to, you may provide your own using the start_lambda option. Setting it to default will re-enable the automatic selection. The option lambda_factor sets the factor by which lambda is increased or decreased whenever the chi-squared target function increased or decreased significantly. Setting it to default re-enables the default factor of 10.0.
The script option may be used to specify a gnuplot command to be executed when a fit is interrupted---see fit. This setting takes precedence over the default of replot and the environment variable FIT_SCRIPT.
If the covariancevariables option is turned on, the covariances between final parameters will be saved to user-defined variables. The variable name for a certain parameter combination is formed by prepending "FIT_COV_" to the name of the first parameter and combining the two parameter names by "_". For example given the parameters "a" and "b" the covariance variable is named "FIT_COV_a_b".
In version 5 the syntax of the fit command changed and it now defaults to unitweights if no 'error' keyword is given. The v4 option restores the default behavior of gnuplot version 4, see also fit.