Question about Chi^2/NDF

Dear Root experts,

I tried to apply the “expo” fitting function for normalized and non-normalized histograms with the same fitting range, but I got two different chi^2/ndf results as below, Is that ordinary as I think chi^2/ndf must give the same value in both?


Thanks a lot in advance

I guess @moneta can help but may be provide a small macro reproducing your problem.

1 Like

Thanks,
I think the problem is only in the case of the histogram with normalizing data, I mean when divide the histogram with the total number of observation,

here is another example that shows the same problem (in case of normalized data)
Which gives chi^2/ndf = 5.89957e-06/113 as in the photo below

The macro file that generates this histogram is
Drawh1.cc (17.2 KB)

Hi,
How did you scale the histogram ? When scaled it needs to have the error stored, i.e. you need to call TH1::Sumw2(). This is done normally automatically when calling TH1::Scale in not too old ROOT versions.

Lorenzo

1 Like

Thanks a lot for your help,

I scaled the histogram by dividing the y axis by the total number of events.

It seems that the problem is in the error as you kindly illustrated, I didn’t include the error for every bin in the histogram,

but if you please what will be the case if my data doesn’t have an error, i.e. I have only the x and y values without an error bar, Is there any solution for that?

If you don’t have an error in the histogram, by default is computed as sqrt(bin_content). Now if you scale the bin content you don’t want to have the error computed as sqrt ( scale_factor * bin_content), but as scale_factor * sqrt(bin_content).
This is done automatically by you use TH1::Scale for scaling the histogram. Otherwise, if you scale the histogram by calling SetBinContent you need to call also SetBinError.

Lorenzo

1 Like

Many Thanks, you really helped me alot.

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