2.7 Function Fitting

It is possible to fit functional forms to data points in datafiles using the fit command. A simple example might be:

f(x) = a*x+b
fit f(x) 'datafile' index 1 using 2:3 via a,b

The coefficients to be varied are listed after the keyword ``via''; the keywords index, every and using have the same meanings as in the plot command.2.5

This is useful for producing best-fit lines2.6, and also has applications for estimating the gradients of datasets. The syntax is essentially identical to that used by gnuplot, though a few points are worth noting:

At the end of the fitting process, the best-fitting values of each parameter are output to the terminal, along with an estimate of the uncertainty in each. Additionally, the Hessian, covariance and correlation matrices are output in both human-readable and machine-readable formats, allowing a more complete assessment of the probability distribution of the parameters.

Dominic Ford 2006-09-09