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);
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();
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
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)