16#ifndef TEFFiciencyHelper_h
17#define TEFFiciencyHelper_h
43 const double term1 = pow(rho/
fRho_hat,
x);
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; };
69template <
typename Sorter>
85 bool Find_rho_set(
const double rho,
const int ntot,
int& x_l,
int& x_r)
const {
88 std::vector<BinomialProbHelper> probs;
89 for (
int i = 0; i <= ntot; ++i)
91 std::sort(probs.begin(), probs.end(),
fSorter);
98 const double target = 1 -
fAlpha;
103 for (
int i = 0; i <= ntot &&
sum < target; ++i) {
104 sum += probs[i].Prob();
105 const int&
x = probs[i].X();
106 if (
x < x_l) x_l =
x;
107 if (
x > x_r) x_r =
x;
115 bool Neyman(
const int ntot,
const int nrho,
double* rho,
double* x_l,
double* x_r) {
117 for (
int i = 0; i < nrho; ++i) {
131 const double tol = 1
e-9;
132 double rho_min, rho_max, rho;
133 rho_min = rho_max = rho = 0.;
138 rho_min = 0; rho_max = 1;
139 while (std::abs(rho_max - rho_min) > tol) {
140 rho = (rho_min + rho_max)/2;
151 rho_min = 0; rho_max = 1;
152 while (std::abs(rho_max - rho_min) > tol) {
153 rho = (rho_min + rho_max)/2;
183 return l.LRatio() >
r.LRatio();
Implement noncentral binomial confidence intervals using the Neyman construction.
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)
Helper class impelementing the binomial probability and the likelihood ratio used for ordering the in...
BinomialProbHelper(double rho, int x, int n)
Namespace for new Math classes and functions.
tbb::task_arena is an alias of tbb::interface7::task_arena, which doesn't allow to forward declare tb...
bool operator()(const BinomialProbHelper &l, const BinomialProbHelper &r) const
static uint64_t sum(uint64_t i)