I’m trying to fit a histogram (‘value’) with a poisson function.
The following code is what I tried:
f1 = ROOT.TF1("f1","[0]*ROOT.TMath.Power(([1]/[2]),(x/[2]))*(ROOT.TMath.Exp( ([1]/[2])))/ROOT.TMath.Gamma((x/[2])+1)", 0, 5)
f1.SetParameters(1, 1, 1)
values.Fit('f1', 'R')
fit = values.GetFunction('f1')
fit.Draw('same')
However I get the following error and I don’t know why:
Error in <TFormula::Compile>: Bad numerical expression : "ROOT.TMath.Power(([1]/[2]),(x/[2]))"
Error in <TF1::TF1>: function: f1/[0]*ROOT.TMath.Power(([1]/[2]),(x/[2]))*(ROOT.TMath.Exp(-([1]/[2])))/ROOT.TMath.Gamma((x/[2])+1) has 0 parameters instead of 1
Unknown function: f1
Traceback (most recent call last):
File "Ansprechmuster3.py", line 242, in <module>
fit.Draw('same')
ReferenceError: attempt to access a null-pointer
So something is wrong with “ROOT.TMath.Power(([1]/[2]),(x/[2]))” but I really don’t have an idea.
Does anybody know what’s the problem?
Thanks in advance!
However I’ve got a new problem now:
Despite setting SetOptFit to 0111 (like it is said in the ROOT manual) the reduced chi square isn’t shown in the statistics box (parameters 0-2 are displayed though).
Any idea why?