1

I have this set of data that want to fit with gnuplot using the function f(x) = exp(A+ B/(x-x0)) where A,B and x0 are my set of parameters to fit

# x   f(x)
0.382 8.29023731095968 
0.509 6.36124122026352 
0.637 4.66938977764103 
0.764 3.3194714217965
0.891 2.15140777817893
1.019 1.15428884806615 
1.146 0.262232461832655 

I have try it with

fit log(f(x)) 'data.dat' using 1:(log($2)) via A, B, x0

also have defined the function as f(x) = A+ B/(x-x0) and tried with

fit f(x) 'data.dat' using 1:(log($2)) via A, B, x0

and then plot exp(f(x))

The code works but the fitted parameters are not fine, because when I plot the curve and the points together not make sense. Is this fit too complicate for gnuplot?

1 Answer 1

2

Fitting can fail if you have an inappropriate function or if you have starting values which might make it difficult for the fitting procedure to converge. In your case, I guess x0 is an important parameter. You should help the gnuplot fitting algorithm a little to have a chance to find reasonable values. Here, I guess x0=1.5 is a reasonable starting value. If this is not sufficient and if your model permits you might want to add additional variables or terms to get a better fit.

Code:

### fitting with appropriate starting values
reset session

$Data <<EOD
0.382 8.29023731095968
0.509 6.36124122026352
0.637 4.66938977764103
0.764 3.3194714217965
0.891 2.15140777817893
1.019 1.15428884806615
1.146 0.262232461832655
EOD

A = 1
B = 1
x0 = 1.5
f(x) = exp(A + B/(x-x0))
set fit nolog

fit f(x) $Data u 1:2 via A,B,x0

plot $Data u 1:2 w lp pt 7 ti "Data",\
     f(x) w l lc rgb "red" ti "Fit"
### end of code

Result:

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
A               = 4.61445          +/- 0.3907       (8.466%)
B               = 3.57094          +/- 0.8876       (24.86%)
x0              = 1.80616          +/- 0.1371       (7.593%)

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.