Problems with errors in FIT

I was trying to do a linear fit but it isn’t working very well. When I try to fit it with errors my function’s parameters assumes values that don’t make sense!

With error in x values

Without error in x values

My code and data are attached.
data.txt (159 Bytes)
linear.cpp (1.5 KB)

The question is: Why when I set all errors for X values equals to 0.0005 it gives a bad fit?

In ROOT, before you try to fit your graph or histogram, you MUST set “reasonable” initial values for ALL parameters of your function (except for some “built-in” formulas, like “gaus”, for which the standard fit procedure can automatically “guess” them), otherwise the fitting procedure may easily misbehave.

So, try something like: f->SetParameters(-3000., 300.);

See also the “initial pre-fit” + “final fit” trick in:

1 Like

It worked! Thanks!:smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.