fit [<range specifier> ...] <function> '<datafile>' [index <index specifier>] [using <using specifier>] via <variable>[, <variable>, ...]
The fit command may be used to fit functional forms to data points in datafiles. 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.
This is useful for producing best-fit lines and also has applications for estimating the gradients of datasets. The syntax is essentially identical to the used by gnuplot, though a few points are worth noting, which are outlined in Section 2.9.