57 for (i=0 ; i<1000 ; i++) {
76 if (
n<1000 && nSigma==1.) {
100 oocoutE(
nullptr,Plotting) <<
"RooHistError::getPoissonInterval: cannot calculate interval for n = " <<
n << endl;
106 mu1=
n - sqrt(
n+0.25) + 0.5;
107 mu2=
n + sqrt(
n+0.25) + 0.5;
115 return getInterval(&upper,&lower,(
double)
n,1.0,mu1,mu2,nSigma);
119 return getInterval(&upper,
nullptr,(
double)
n,1.0,mu1,mu2,nSigma);
128 double &asym1,
double &asym2,
double nSigma)
const
132 oocoutE(
nullptr,Plotting) <<
"RooHistError::getPoissonInterval: cannot calculate interval for n,m = " <<
n <<
"," <<
m << endl;
137 if(
n == 0 &&
m == 0) {
144 if ((
n>100&&
m>100)) {
147 double asym = 1.0*(
N-M)/(
N+M) ;
148 double approxErr = sqrt(4.0*
n/(
N+M)*(1-
N/(
N+M))/(
N+M)) ;
150 asym1 = asym-nSigma*approxErr ;
151 asym2 = asym+nSigma*approxErr ;
169 status=
getInterval(&upper,&lower,(
double)(
n-
m)/(
n+
m),0.1,asym1,asym2,nSigma);
172 status=
getInterval(&upper,
nullptr,(
double)(
n-
m)/(
n+
m),0.1,asym1,asym2,nSigma);
191 double &asym1,
double &asym2,
double nSigma)
const
195 oocoutE(
nullptr,Plotting) <<
"RooHistError::getPoissonInterval: cannot calculate interval for n,m = " <<
n <<
"," <<
m << endl;
200 if(
n == 0 &&
m == 0) {
210 double asym = 1.0*(
N)/(
N+M) ;
211 double approxErr = sqrt(4.0*
n/(
N+M)*(1-
N/(
N+M))/(
N+M)) ;
213 asym1 = asym-nSigma*0.5*approxErr ;
214 asym2 = asym+nSigma*0.5*approxErr ;
233 status=
getInterval(&upper,&lower,eff,0.1,asym1,asym2,nSigma*0.5);
236 status=
getInterval(&upper,
nullptr,eff,0.1,asym1,asym2,nSigma*0.5);
258 double stepSize,
double &lo,
double &
hi,
double nSigma)
const
261 assert(
nullptr != Qu ||
nullptr != Ql);
265 double alpha= 0.5*(1-beta);
269 double loProb(1),hiProb(0);
270 if(
nullptr != Ql) loProb= (*Ql)(&pointEstimate);
271 if(
nullptr != Qu) hiProb= (*Qu)(&pointEstimate);
273 if (Qu && (
nullptr == Ql || loProb > alpha + beta)) {
276 double target= loProb - beta;
281 else if(Ql && (
nullptr == Qu || hiProb < alpha)) {
284 double target= hiProb + beta;
291 lo=
seek(*Ql,pointEstimate,-stepSize,alpha+beta);
292 hi=
seek(*Qu,pointEstimate,+stepSize,alpha);
294 ok= lFinder.findRoot(lo,lo,lo+stepSize,alpha+beta);
297 if(!ok)
oocoutE(
nullptr,Plotting) <<
"RooHistError::getInterval: failed to find root(s)" << endl;
310 double min(
f.getMinLimit(1)),max(
f.getMaxLimit(1));
311 double x(startAt), f0=
f(&startAt) -
value;
315 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
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).