I’d like to fit a histogram with a log scale on both axes, but I get a weird result. Here’s the relevant code (PyROOT, Python 2.7.2, ROOT 5.30.01). I’m posting it here as I suppose it’s not a python related issue.
You cannot fit a polynomial to an histogram that is linear in the logx logy scale.
Your fitted function must be linear in the log scale:
log y = A * logx + B
Therefore in the non-log scale the equivalent function is
y = P0 * X ^ (P1)
which in ROOT you can write as
TF1 * f1 = new TF1("f1","[0]*TMath::Power(x,[1])");
and the use for fitting. Remember You need to set also some reasonable value of the initial parameters before fitting
Best Regards,
Lorenzo