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) {
133 const double tol = 1e-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;
176 void Set(
double l,
double u) { fLower =
l; fUpper = u; }
Namespace for new ROOT classes and functions.
bool Find_rho_set(const double rho, const int ntot, int &x_l, int &x_r) const
void Set(double l, double u)
double pow(double, double)
static Vc_ALWAYS_INLINE Vector< T > abs(const Vector< T > &x)
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.
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)