i want to use gnuplot to get fit parameters of a first degree polynomial equation (F(x)=a*x+b) for many curvers. Some of the curves are represented exactly straight lines.
For example if my data look like
1 1
2 2
3 3
4 4
which can be represented with the f(x)=x (param a=0, b=0).
But the following gnuplot code
# regression line
f(x) = a*x + b
fit f(x) './test.dat' u 1:2 via a, b
fails to compute fit params giving the message below
Singular matrix in Invert_RtR
update: It seems that gnuplot does not "crash" if i define the number of iterations for fit function
FIT_MAXITER = 1
# regression line
f(x) = a*x + b
fit f(x) './test.dat' u 1:2 via a, b
It should be a=1 and b=0. But gnuplot gives
Final set of parameters Asymptotic Standard Error
======================= ==========================
a = 0.989067 +/- 0.004339 (0.4387%)
b = 0.0761393 +/- 0.02692 (35.36%)
How can i "force" gnuplot compute the correct values of a and b?