Wrong fit with error bars in Gnuplot

偶尔善良 提交于 2020-01-15 04:57:31

问题


Fitting without errors (works)

I made a simple linear fit in Gnuplot 5.0 using the command:

f(x)=a*x+b
fit f(x) 'file.dat' using 1:2 via a,b

I get the output:

degrees of freedom    (FIT_NDF)                        : 6
rms of residuals      (FIT_STDFIT) = sqrt(WSSR/ndf)    : 0.00794747
variance of residuals (reduced chisquare) = WSSR/ndf   : 6.31623e-05

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
p1              = -0.00964423      +/- 0.0004976    (5.159%)
p2              = 1.07794          +/- 0.01908      (1.77%)

The result is this:

Fitting with errors

Then I added very tiny error bars just to see how they influence the fitting results (expecting the difference from the previous case to be very small), but using the command

f(x)=a*x+b
fit f(x) 'file.dat' using 1:2:3 yerrors via a,b

I get a completely wrong fit:

The output is:

degrees of freedom    (FIT_NDF)                        : 6
rms of residuals      (FIT_STDFIT) = sqrt(WSSR/ndf)    : 750.565
variance of residuals (reduced chisquare) = WSSR/ndf   : 563348
p-value of the Chisq distribution (FIT_P)              : 0

Final set of parameters            Asymptotic Standard Error
=======================            ==========================
p1              = -0.0115247       +/- 0.0003419    (2.967%)
p2              = 1.15636          +/- 0.01483      (1.282%)

Furthermore, if I set the errors to be much larger, the output remains the one I had for tiny errors. Do anyone have suggestions? What did I do wrong?

Data

  y                          x                         dy
  0.64345112296614271        45.082768716145587        6.6513808914832773E-004
  0.71703932263695935        38.322543680055119        1.8140129703996476E-004
  0.62214826712778870        46.283953074076770        1.2093419803380392E-004
  0.70999997854232788        39.152893923419398        3.9303614359375108E-004
  0.75723404482236245        33.204658354605364        6.6513808915369822E-004
  0.69366599317566635        39.410047372618159        5.8653086043387384E-003
  0.75948892906677234        33.491967428263528        6.6513808915369822E-004
  0.79365751671683227        28.533494222921814        1.2758557891916475E-002

where for the first plot I just used the first two columns and for the second one I used the third for the error in y.

来源:https://stackoverflow.com/questions/46080858/wrong-fit-with-error-bars-in-gnuplot

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!