DRafael
DRafael

Reputation: 13

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.

Upvotes: 0

Views: 375

Answers (2)

DRafael
DRafael

Reputation: 13

Thank you for your method. I understand gnuplot uses non linear least squares method for fitting.
I found one solution is to use the model y=a+b*exp(-c*c*x), I also found better initial values and it worked. anyway I have this other dataset:
2 -878.11598213
6 -878.08846509
10 -878.08105262
19 -878.07882425
28 -878.07793702
44 -878.07755010
60 -878.07738151
85 -878.07729504
110 -878.07725107
And gnuplot fit does the work but really bad. instead I used your method, here I show a comparison: gnuplot fit and jjaquelin comparison

it is way better.

Upvotes: 1

JJacquelin
JJacquelin

Reputation: 1705

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

Upvotes: 0

Related Questions