Bin width independent fitting

Hello,

So say I have a histogram that I want to fit a gaussian to. Is it possible to have a very fine binwidth and yet the gaussian fitting well? I think even in a fine bin width case, the density of populated bins decreases as you reach the gaussian tails, so one should be able to take this into account when fitting? (ie, more bins are populated towards the center and fewer towards the tails)

For example from this tutorail, if I change N is it possible to obtain the same gaussian mean and sigma?
if N=10000000 I get different mu and sigma than if N were 100.

TH1F *hpx = new TH1F(“hpx”,“hpx”,N,-10.,10.);
TF1 *f1 = new TF1(“f1”,“gaus”,-10.,10.);
// Fill histograms randomly
gRandom->SetSeed();
Float_t px, py, pz;
const Int_t kUPDATE = 1000;
for (Int_t i = 0; i < 25000; i++) {
gRandom->Rannor(px,py);
Float_t random = gRandom->Rndm(1);
hpx->Fill(px);

}
hpx->Sumw2();
hpx->Fit(“f1”,“emr”);
hpx->Draw();

cout<GetParameter(1)<<endl;
cout<GetParameter(2)<<endl;

Thanks!

  • Sujeewa

Hi,

If you increase the number of bins and using the least square, you will get a bias results due to the low statistics of the bins. You need to use the poisson likelihood method (option “L” ) and it should be fine. This should be equivalent to an unbinned maximum likelihood fit in the limit of very large number of bins (i.e. one entry/bin)
See for example page 5 in pdg.lbl.gov/2009/reviews/rpp2009 … istics.pdf

Best Regards

Lorenzo