2

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:

Data and fit without errors

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:

Data and fit with errors

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.

Wrzlprmft
  • 4,234
  • 1
  • 28
  • 54
Matteo Lucca
  • 21
  • 1
  • 5
  • Why do you think it's a completely wrong fit? The error for the point at x~28 is 2 orders of magnitude larger than some of the other errors, so naturally, your fit will be weighted towards the data points with the smaller errors. In this case, that would be the points at x=38, 46 and 39, which seems to agree with the graph. –  Sep 09 '17 at 10:23

0 Answers0