Calculation of fit errors

Consider this script:

void gausserrors()
{
  gStyle -> SetOptFit(kTRUE);
  TH1F * h = new TH1F("h1", "h1", 11, -5.0, 5.0);
  h -> FillRandom("gaus", 500);
  //for	(unsigned char bind = 1; bind <= h -> GetNbinsX(); bind ++)
  //  {
  //	h -> SetBinError(bind, 0.0);
  //  }
  h -> Fit("gaus");
  TCanvas *c = new TCanvas();
  h -> Draw();
}

How are the errors on fit parameters computed? And why does the fit fail if the bin errors are set to 0.0 (instead of producing a fit with error 0.0)?


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Bins with zero errors are called “empty bins”. See: TH1::Fit

There could be an option that produces the best fitting curve and forget about chi square in case of bins of nonzero content and zero errors.

Hi,
if you use a Likelihood fit, should work way better for a gaussian fit of an histogram , especially with only 500 entry. The likelihood treats better the bins with low number of entries

The method to use the Likelihood fit is

h -> Fit("gaus","L");

Cheers,
Stefano

1 Like

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