Search code examples
gnuplotnon-linear-regression

gnuplot - nonlinear curve fitting, parameter initialization and boundary definition


I'm trying NLCF in Gnuplot. My question is how to set bounds and initialize parameters for a function of the following form:

g (x) = k1*x**(0.5) + k2*x + a*(1-exp(-b*x));

I am looking for the values of "k1", "k2", "a" and "b" for the data:

x y
0 0
60 0.04959
300 0.1405
600 0.21488
900 0.27273
1200 0.35537
2400 0.59917
3000 0.72727
3600 0.82645
5400 0.92975
7200 0.97107
9000 0.98347
10800 0.9876
12600 0.9876
16200 0.9876
18000 1.02066
23400 1.00413
27000 1

Unfortunately, I got negative values which may not make sense. I have tried to set bounds for the parameters (i.e. k1, k2, a, b> 0), but I can't do that in Gnuplot. Thanks for any help and tip.


Solution

  • To initialise the variables just define them before the fit. You should choose reasonable starting guesses for the fit to converge; I was getting a pretty decent result with the following guess:

    k1=1e-9
    k2=1e-9
    a=1
    b=5e-4
    

    I plotted your data points and the function and kept trying out different starting values, until the function looked good, and then ran the fit.