Search code examples
gnuplotcurve-fitting

gnuplot fit undefined value during function evaluation


I have the datafile:

10.0000 -330.12684910
15.0000 -332.85109334
20.0000 -333.85785274
25.0000 -334.18315783
30.0000 -334.28078907
35.0000 -334.30486903
40.0000 -334.30824069
45.0000 -334.30847874
50.0000 -334.30940105
55.0000 -334.31091085
60.0000 -334.31217217

The commands a used to fit this

f(x) = a+b*exp(c*x)
fit f(x) datafile via a, b, c

didn't get the negative exponential that I expected, then just to see how the hyperbola fitted I tried

f(x) = a+b/x 
fit f(x) datafile via a, b

but decided to do this:

f(x) = a+b*exp(-c*x)
fit f(x) datafile via a, b, c

and it worked. I continued doing fits but in some point it started to mark this error undefined value during function evaluation. I restarted the session and deleted the fit.log file, I thought it was a gnuplot bug but since then I always receive the undefined value error. I've been reading similar issues. It could be a, b, c seeds but I have introduced very similar values to the ones a received that time it fitted well but didn't work. I'm thinking the problem might be chaotic or I'm doing something wrong.


Solution

  • I don't know the algorithm used by gnuplot. Probably an iterative method starting from guessed values of the parameters. The difficulty might come from not convenient initial values and/or from no convergence of the process.

    From my own calculus the result is close to the values below. The method, which is not iterative and doesn't require initial guess, is explained in the paper : https://fr.scribd.com/doc/14674814/Regressions-et-equations-integrales

    enter image description here

    enter image description here

    FOR INFORMATION :

    The linearisation of the regression is obtained thanks to the integral equation

    enter image description here

    to which the function to be fitted is solution.

    The paper referenced above is mainly written in French. It is pratially translated in : https://scikit-guess.readthedocs.io/en/latest/appendices/references.html