Setting 2 sigma confidence interval

Hi all,

I am using ROOT version 4.01 on a linux machine.

I am currently fitting a simple gaussian plus constant (a background) to a data set. I would like to extract from the fit a 2 sigma confidence level (90%). Naively speaking, this simply means going out to the 2 sigma point in the chi-square distribution and using those fit parameters which are excluded to 90%.

Does someone have a suggestion as to how I would do this?

Cheers, david

Depending what you want to do, see

see also tutorials



Thanks for the reply. I now have a futher question.

I would like to use the TLimit class to evaluate the 95% CL for a (Gaussian + flat BCKG) on a data set. I currently extract a TF1 best fit for this ‘hypothesis’ from the normal fitting method, and this is the “signal + background” that I would like to obtain the limit for.

Is there a way to use this TF1 gaussian in the TLimit class instead of generating a TH1 gaussian histogram? If not, does it make sense to simply generate the TH1 gaussian from teh TF1 fit and then use to create the desired TLimitDataSource?

Thank you agian.


Just to clarify (after attempting a few different things) ideally I would like to find the 95% CL for a gaussian function compared to a binned data set (a normal histogram).

It seems to me like the TLimit class is exactly what I want, except this requires as its input a histogram, not a function.

A further complication is that this gaussian function that I want to fit is only in a small region of the total histogram range. Thus, when I create a gaussian histogram from my TF1 function by using signalH->FillRandom("peakfit",10000); the resulting histogram only has the range specified by the fit.

Will the TLimit class accept input histograms (from the TLimitDataSource) with different ranges?

Thanks for all the help, once again.



Histograms in TLimit must have the same range and same binning.

On the other hand, it makes sense to replace the function by an histogram, if you take care of the normalization.
Make sure also to disable the “statistical uncertainties” as it is designed to handle background and signal histograms produced by Monte Carlo methods.


Well, I have taken my fit functions obtained from curhisto->Fit("fitfcn","QR","PE1"); and converted them to histograms in order to use them as input for a TLimitDataSource in TLimit.

However, when the CLs are returned (exatly as in the tutorial) all CL = 1. I am not sure why.

Moreover, since all I want is the VALUE of the FIT PARAMETER at 2\sigma from whatever minima is found in the parameter space of the fit, can I get something like this directly from TMinuit?

For example, the fitting package SAS (FORTRAN) will always return a 95% CL for each paramter in a fit, along with the best fit values (those values at the minimum of the parameter space found).


If CLb is one, then your “background” is to high for the data. It indicates a “clear deficit”, beyond 4 sigmas (with default number of MC tries).
Then, CLs+b will also be one (since it looks at s+b, higher than b), and CLs = CLs+b/CLb too.

You should check the normalization of your histograms.

But anyway, TLimit is probably not well adapted to your aim. But I don’t know TMinuit enough to help you more in that direction.