16 #ifndef TEFFiciencyHelper_h 17 #define TEFFiciencyHelper_h 44 const double term2 =
pow((1 - rho)/(1 -
fRho_hat), n - x);
45 fLRatio = (term1 == 0. || term2 == 0.) ? 0. : term1 * term2;
50 int X ()
const {
return fX; };
51 int N ()
const {
return fN; };
71 template <
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;
121 Find_rho_set(rho[i], ntot, xL, xR);
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;
143 Find_rho_set(rho,
int(n), x_l, x_r);
153 rho_min = 0; rho_max = 1;
154 while (std::abs(rho_max - rho_min) > tol) {
155 rho = (rho_min + rho_max)/2;
156 Find_rho_set(rho,
int(n), x_l, x_r);
165 double Lower()
const {
return fLower; }
166 double Upper()
const {
return fUpper; }
176 void Set(
double l,
double u) { fLower =
l; fUpper = u; }
static long int sum(long int i)
Namespace for new ROOT classes and functions.
void Set(double l, double u)
double pow(double, double)
bool operator()(const BinomialProbHelper &l, const BinomialProbHelper &r) const
double binomial_pdf(unsigned int k, double p, unsigned int n)
Probability density function of the binomial distribution.
bool Find_rho_set(const double rho, const int ntot, int &x_l, int &x_r) const
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Namespace for new Math classes and functions.
BinomialProbHelper(double rho, int x, int n)
bool Neyman(const int ntot, const int nrho, double *rho, double *x_l, double *x_r)
void Calculate(const double X, const double n)