I’m trying to get a confidence level based on chi2 and degrees of freedom; after some digging I found this TMath::Prob function. When I try to use it, however, it returns values on the order of 10^8. Here’s the relevent part of my code:
(the print chi2dof line returns a value of ~3)
Int_t dof = 92;
printf(“chi2/dof is : %f \n”,RecoilMassFrame->chiSquare());
Double_t chi2dof = chi2.getVal() / dof;
printf(“chi2 is : %f \n”, chi2dof);
Double_t conf1 = “TMath::Prob(chi2dof,Int_t dof)”;
printf(“Confidence Level : %f \n”,conf1);
I don’t think it should matter but this is contained within a function to fit using RooFit. Any help would be appreciated.
TMath::Prob takes chi2, not chi2/dof.
Thanks, but that just returned a different number on the same order of magnitude. The problem also seems to have something to do with dof, as
Double_t conf1 = “TMath::Prob(chisq,dof)”;
Double_t conf1 = “TMath::Prob(chisqbig,Int_t dof)”;
give different numbers, but changing the value of dof doesn’t seem to have an effect.
I’ve also discovered that if I make dof negative the function does not return 0 like it should, it still returns something on the order of 10^8. This is also the case if I remove dof from the function call, as in
Double_t conf1 = “TMath::Prob(chi2)”;
do you really have quotation marks around the calls to TMath::Prob?! You do this very consistently in your postings, so I’m getting a bit worried now…
Could you send us a working macro which demonstrates what you see? It might just be
printf("%f\n", TMath::Prob(42.,17));or whatever your actual values for chi2 and ndf are.
It would seem something has been changed to fix this; and yes, as stupid as it seems I did have the quotes there the whole time. Without them I got some error I can’t remember exactly which seemed to imply that Prob was defined but not usable. This error has gone away as well; in case it’s not obvious I’m at best mediocre at coding so I can’t make a good guess as to what was wrong. I am now getting reasonable numbers, but since I did have the quotes there the whole time I’m not sure at which point I fixed the other issues. Unfortunately I now have to deal with my bad fits, as the values
chisq = 294
dof = 92
return a CL of 0, which seems reasonable (especially when you look at my fit). Other fits return good CL values though, so I believe things are working. Thank you for your help.