如何获得更好的指数拟合?

时间:2017-03-19 19:44:00

标签: gnuplot curve-fitting data-fitting

如何获得更好的指数拟合?

data.log

# +------+-----------+-------+
# | temp | viscosity | error |
# +------+-----------+-------+
    303    0.68        0.19
    308    0.47        0.13
    313    0.33        0.09
    318    0.24        0.07
    323    0.17        0.05
    328    0.14        0.04
    333    0.10        0.03
# +------+-----------+-------+

gnuplot代码

f(x) = exp(a / x) + b
fit f(x) 'data/data.log' using 1 : 2 via a, b
plot f(x) w l lw 6 lt 1 lc 8
  
    

result

         

but I need something like this

  

3 个答案:

答案 0 :(得分:2)

我觉得这不合适。也许这个模型错了?

我不是这种粘性的东西,但有些人似乎使用的是具有b*exp(a/x)而不是b+exp(a/x)的Arrhenius型号:

set terminal pngcairo
set output "viscosity.png"

set xrange [303:333]

f(x) = b*exp(a/x) 
fit f(x) 'data.log' using 1 : 2 via a, b
plot f(x) w l , 'data.log' w p pt 7

viscosity

答案 1 :(得分:1)

在这种情况下,二次方程更适合您的数据:

set terminal pngcairo enhanced color dashed font "Alegreya, 14" \
rounded size 800, 600
set output "data.png"

f(x) = exp(a/x)+b
g(x) = c*x**2+d*x+e

fit f(x) "data.log" using 1:2 via a, b
fit g(x) "data.log" using 1:2 via c, d, e
plot f(x) w l ls 1, g(x) w l ls 2, "data.log" using 1:2 with p ls 3

导致:

plot of graph defined above

答案 2 :(得分:0)

您可以考虑在拟合方程中使用偏移量“x”,如下所示:

f(x)= exp(a / x + xoffset)+ b

我有如下所示的良好(未加权)结果,如附图所示:

a =  7.2818728249106498E+03
b =  2.8379411855001473E-02
xoffset = -2.4460749606962697E+01

Degrees of freedom (error): 4
Degrees of freedom (regression): 2
Chi-squared: 9.7614501663e-05
R-squared: 0.999624806989
R-squared adjusted: 0.999437210483
Model F-statistic: 5328.58970008
Model F-statistic p-value: 1.40769795487e-07
Model log-likelihood: 29.1988115147
AIC: -7.48537471847
BIC: -7.50855608316
Root Mean Squared Error (RMSE): 0.00373429093792

a = 7.2818728249106498E+03
       std err: 6.89975E+04
       t-stat: 2.77221E+01
       p-stat: 1.00714E-05
       95% confidence intervals: [6.55257E+03, 8.01117E+03]

b = 2.8379411855001473E-02
       std err: 9.37027E-05
       t-stat: 2.93175E+00
       p-stat: 4.27390E-02
       95% confidence intervals: [1.50339E-03, 5.52554E-02]

xoffset = -2.4460749606962697E+01
       std err: 7.69693E-01
       t-stat: -2.78812E+01
       p-stat: 9.84447E-06
       95% confidence intervals: [-2.68966E+01, -2.20249E+01]

Coefficient Covariance Matrix
[  2.82734819e+09   9.81055346e+04  -9.44267056e+06]
[  9.81055346e+04   3.83970212e+00  -3.28710031e+02]
[ -9.44267056e+06  -3.28710031e+02   3.15401191e+04]

enter model plot