fit [ { <range> } ] <function name>() [ withouterrors ] ( <filename> | { <expression> } | { <vector obj> } ) [ index <value> ] [ using { <expression> } ] via { <variable> }
The fit command can be used to fit arbitrary functional forms to data points read from files. It can be used to produce best-fit lines for datasets or to determine gradients and other mathematical properties of data by looking at the parameters associated with the best-fitting functional form. The following simple example fits a straight line to data in a file called data.dat:
f(x) = a*x+b fit f() 'data.dat' index 1 using 2:3 via a,b
The first line specifies the functional form which is to be used. The coefficients within this function, a and b, which are to be varied during the fitting process are listed after the keyword via in the fit command. The modifiers index, every, select and using have the same meanings in the fit command as in the plot command. When fitting a function of n
n+1
n+1
n
1.0
{a=100,b=50}