64 oocoutE(
nullptr, Plotting) <<
"RooHistError::getPoissonInterval: cannot calculate interval for n = " <<
n
68 if (!(nSigma > 0.0)) {
69 oocoutE(
nullptr, Plotting) <<
"RooHistError::getPoissonInterval: nSigma must be > 0, got " << nSigma << std::endl;
75 const double beta = std::erf(nSigma / std::sqrt(2.0));
76 const double alpha = 1.0 - beta;
91 const double a2 = 0.5 * alpha;
103 double &asym1,
double &asym2,
double nSigma)
const
107 oocoutE(
nullptr,Plotting) <<
"RooHistError::getPoissonInterval: cannot calculate interval for n,m = " <<
n <<
"," <<
m << std::endl;
112 if(
n == 0 &&
m == 0) {
119 if ((
n>100&&
m>100)) {
122 double asym = 1.0*(
N-M)/(
N+M) ;
123 double approxErr = sqrt(4.0*
n/(
N+M)*(1-
N/(
N+M))/(
N+M)) ;
125 asym1 = asym-nSigma*approxErr ;
126 asym2 = asym+nSigma*approxErr ;
144 status=
getInterval(&upper,&lower,(
double)(
n-
m)/(
n+
m),0.1,asym1,asym2,nSigma);
147 status=
getInterval(&upper,
nullptr,(
double)(
n-
m)/(
n+
m),0.1,asym1,asym2,nSigma);
166 double &asym1,
double &asym2,
double nSigma)
const
170 oocoutE(
nullptr,Plotting) <<
"RooHistError::getPoissonInterval: cannot calculate interval for n,m = " <<
n <<
"," <<
m << std::endl;
175 if(
n == 0 &&
m == 0) {
185 double asym = 1.0*(
N)/(
N+M) ;
186 double approxErr = sqrt(4.0*
n/(
N+M)*(1-
N/(
N+M))/(
N+M)) ;
188 asym1 = asym-nSigma*0.5*approxErr ;
189 asym2 = asym+nSigma*0.5*approxErr ;
208 status=
getInterval(&upper,&lower,eff,0.1,asym1,asym2,nSigma*0.5);
211 status=
getInterval(&upper,
nullptr,eff,0.1,asym1,asym2,nSigma*0.5);
233 double stepSize,
double &lo,
double &
hi,
double nSigma)
const
236 assert(
nullptr != Qu ||
nullptr != Ql);
239 double beta= std::erf(nSigma/sqrt(2.));
240 double alpha= 0.5*(1-beta);
246 if(
nullptr != Ql) loProb= (*Ql)(&pointEstimate);
247 if(
nullptr != Qu) hiProb= (*Qu)(&pointEstimate);
249 if (Qu && (
nullptr == Ql || loProb > alpha + beta)) {
252 double target= loProb - beta;
253 hi=
seek(*Qu,lo,+stepSize,target);
257 else if(Ql && (
nullptr == Qu || hiProb < alpha)) {
260 double target= hiProb + beta;
261 lo=
seek(*Ql,
hi,-stepSize,target);
263 ok= lFinder.
findRoot(lo,lo,lo+stepSize,target);
267 lo=
seek(*Ql,pointEstimate,-stepSize,alpha+beta);
268 hi=
seek(*Qu,pointEstimate,+stepSize,alpha);
271 ok= lFinder.
findRoot(lo,lo,lo+stepSize,alpha+beta);
274 if(!ok)
oocoutE(
nullptr,Plotting) <<
"RooHistError::getInterval: failed to find root(s)" << std::endl;
287 double min(
f.getMinLimit(1));
288 double max(
f.getMaxLimit(1));
290 double f0 =
f(&startAt) - value;
294 while(steps-- && (f0*(
f(&
x)-value) >= 0) && ((
x-min)*(max-
x) >= 0));
int Int_t
Signed integer 4 bytes (int).
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.
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).
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 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
Calculate a confidence interval for the expected number of events given n observed (unweighted) event...
static RooAbsFunc * createPoissonSum(Int_t n)
Create and return a PoissonSum function binding.
static RooAbsFunc * createBinomialSum(Int_t n, Int_t m, bool eff)
Create and return a BinomialSum function binding.
double chisquared_quantile_c(double z, double r)
Inverse ( ) of the cumulative distribution function of the upper tail of the distribution with degr...
double chisquared_quantile(double z, double r)
Inverse ( ) of the cumulative distribution function of the lower tail of the distribution with degr...