61 for (i=0 ; i<1000 ; i++) {
80 if (
n<1000 && nSigma==1.) {
104 oocoutE(
nullptr,Plotting) <<
"RooHistError::getPoissonInterval: cannot calculate interval for n = " <<
n << endl;
110 mu1=
n - sqrt(
n+0.25) + 0.5;
111 mu2=
n + sqrt(
n+0.25) + 0.5;
119 return getInterval(&upper,&lower,(
double)
n,1.0,mu1,mu2,nSigma);
123 return getInterval(&upper,0,(
double)
n,1.0,mu1,mu2,nSigma);
132 double &asym1,
double &asym2,
double nSigma)
const
136 oocoutE(
nullptr,Plotting) <<
"RooHistError::getPoissonInterval: cannot calculate interval for n,m = " <<
n <<
"," <<
m << endl;
141 if(
n == 0 &&
m == 0) {
148 if ((
n>100&&
m>100)) {
151 double asym = 1.0*(
N-M)/(
N+M) ;
152 double approxErr = sqrt(4.0*
n/(
N+M)*(1-
N/(
N+M))/(
N+M)) ;
154 asym1 = asym-nSigma*approxErr ;
155 asym2 = asym+nSigma*approxErr ;
173 status=
getInterval(&upper,&lower,(
double)(
n-
m)/(
n+
m),0.1,asym1,asym2,nSigma);
176 status=
getInterval(&upper,0,(
double)(
n-
m)/(
n+
m),0.1,asym1,asym2,nSigma);
195 double &asym1,
double &asym2,
double nSigma)
const
199 oocoutE(
nullptr,Plotting) <<
"RooHistError::getPoissonInterval: cannot calculate interval for n,m = " <<
n <<
"," <<
m << endl;
204 if(
n == 0 &&
m == 0) {
214 double asym = 1.0*(
N)/(
N+M) ;
215 double approxErr = sqrt(4.0*
n/(
N+M)*(1-
N/(
N+M))/(
N+M)) ;
217 asym1 = asym-nSigma*0.5*approxErr ;
218 asym2 = asym+nSigma*0.5*approxErr ;
237 status=
getInterval(&upper,&lower,eff,0.1,asym1,asym2,nSigma*0.5);
240 status=
getInterval(&upper,0,eff,0.1,asym1,asym2,nSigma*0.5);
262 double stepSize,
double &lo,
double &
hi,
double nSigma)
const
265 assert(0 != Qu || 0 != Ql);
269 double alpha= 0.5*(1-beta);
273 double loProb(1),hiProb(0);
274 if(0 != Ql) loProb= (*Ql)(&pointEstimate);
275 if(0 != Qu) hiProb= (*Qu)(&pointEstimate);
277 if (Qu && (0 == Ql || loProb > alpha + beta)) {
280 double target= loProb - beta;
285 else if(Ql && (0 == Qu || hiProb < alpha)) {
288 double target= hiProb + beta;
295 lo=
seek(*Ql,pointEstimate,-stepSize,alpha+beta);
296 hi=
seek(*Qu,pointEstimate,+stepSize,alpha);
298 ok= lFinder.findRoot(lo,lo,lo+stepSize,alpha+beta);
301 if(!ok)
oocoutE(
nullptr,Plotting) <<
"RooHistError::getInterval: failed to find root(s)" << endl;
314 double min(
f.getMinLimit(1)),max(
f.getMaxLimit(1));
315 double x(startAt), f0=
f(&startAt) -
value;
319 while(steps-- && (f0*(
f(&
x)-
value) >= 0) && ((
x-min)*(max-
x) >= 0));
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Abstract interface for evaluating a real-valued function of one real variable and performing numerica...
Implement the abstract 1-dimensional root finding interface using the Brent-Decker method.
bool findRoot(double &result, double xlo, double xhi, double value=0) const override
Do the root finding using the Brent-Decker method.
RooHistError is a singleton class used to calculate the error bars for each bin of a RooHist object.
bool getBinomialIntervalAsym(Int_t n, Int_t m, double &a1, double &a2, double nSigma=1) const
Return 'nSigma' binomial confidence interval for (n,m).
double _poissonLoLUT[1000]
static const RooHistError & instance()
Return a reference to a singleton object that is created the first time this method is called.
bool getBinomialIntervalEff(Int_t n, Int_t m, double &a1, double &a2, double nSigma=1) const
Return 'nSigma' binomial confidence interval for (n,m).
bool getPoissonIntervalCalc(Int_t n, double &mu1, double &mu2, double nSigma=1) const
Calculate a confidence interval for the expected number of events given n observed (unweighted) event...
bool getInterval(const RooAbsFunc *Qu, const RooAbsFunc *Ql, double pointEstimate, double stepSize, double &lo, double &hi, double nSigma) const
Calculate a confidence interval using the cumulative functions provided.
double seek(const RooAbsFunc &f, double startAt, double step, double value) const
Scan f(x)-value until it changes sign.
bool getPoissonInterval(Int_t n, double &mu1, double &mu2, double nSigma=1) const
Return a confidence interval for the expected number of events given n observed (unweighted) events.
static RooAbsFunc * createPoissonSum(Int_t n)
Create and return a PoissonSum function binding.
RooHistError()
Construct our singleton object.
double _poissonHiLUT[1000]
static RooAbsFunc * createBinomialSum(Int_t n, Int_t m, bool eff)
Create and return a BinomialSum function binding.
Double_t Erf(Double_t x)
Computation of the error function erf(x).