16#ifndef TEFFiciencyHelper_h
17#define TEFFiciencyHelper_h
45 fLRatio = (term1 == 0. || term2 == 0.) ? 0. : term1 * term2;
50 int X ()
const {
return fX; };
51 int N ()
const {
return fN; };
71template <
typename Sorter>
87 bool Find_rho_set(
const double rho,
const int ntot,
int& x_l,
int& x_r)
const {
90 std::vector<BinomialProbHelper> probs;
91 for (
int i = 0; i <= ntot; ++i)
93 std::sort(probs.begin(), probs.end(),
fSorter);
100 const double target = 1 -
fAlpha;
105 for (
int i = 0; i <= ntot &&
sum < target; ++i) {
106 sum += probs[i].Prob();
107 const int&
x = probs[i].X();
108 if (
x < x_l) x_l =
x;
109 if (
x > x_r) x_r =
x;
117 bool Neyman(
const int ntot,
const int nrho,
double* rho,
double* x_l,
double* x_r) {
119 for (
int i = 0; i < nrho; ++i) {
120 rho[i] = double(i)/nrho;
133 const double tol = 1
e-9;
134 double rho_min, rho_max, rho;
135 rho_min = rho_max = rho = 0.;
140 rho_min = 0; rho_max = 1;
141 while (std::abs(rho_max - rho_min) > tol) {
142 rho = (rho_min + rho_max)/2;
153 rho_min = 0; rho_max = 1;
154 while (std::abs(rho_max - rho_min) > tol) {
155 rho = (rho_min + rho_max)/2;
185 return l.LRatio() >
r.LRatio();
double pow(double, double)
bool Neyman(const int ntot, const int nrho, double *rho, double *x_l, double *x_r)
bool Find_rho_set(const double rho, const int ntot, int &x_l, int &x_r) const
void Set(double l, double u)
void Calculate(const double X, const double n)
BinomialProbHelper(double rho, int x, int n)
double binomial_pdf(unsigned int k, double p, unsigned int n)
Probability density function of the binomial distribution.
Namespace for new Math classes and functions.
Namespace for new ROOT classes and functions.
bool operator()(const BinomialProbHelper &l, const BinomialProbHelper &r) const
static long int sum(long int i)