CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
BinomialInterval Class Referenceabstract

#include <BinomialInterval.h>

Inheritance diagram for BinomialInterval:
BinomialNoncentralInterval< Sorter > BinomialNoncentralInterval< FeldmanCousinsSorter > BinomialNoncentralInterval< SterneSorter > ClopperPearsonBinomialInterval FeldmanCousinsBinomialInterval SterneBinomialInterval

Public Types

enum  tail_type { equal_tailed, lower_tailed, upper_tailed }
 

Public Member Functions

double alpha () const
 
virtual void calculate (const double successes, const double trials)=0
 
bool contains (double rho)
 
double coverage_prob (const double rho, const int trials)
 
void dump (const int trials_min, const int trials_max)
 
void init (const double alpha, const tail_type t=equal_tailed)
 
double length () const
 
double lower () const
 
virtual const char * name () const =0
 
virtual bool neyman (const int ntot, const int nrho, double *rho, double *x_l, double *x_r)
 
void scan_ntot (const double rho, const int ntot_min, const int ntot_max, double *ntot, double *prob)
 
void scan_rho (const int ntot, const int nrho, double *rho, double *prob)
 
double upper () const
 
virtual ~BinomialInterval ()=default
 

Protected Member Functions

void set (double l, double u)
 

Protected Attributes

double alpha_
 
double alpha_min_
 
double kappa2_
 
double kappa_
 
double lower_
 
tail_type type_
 
double upper_
 

Detailed Description

Definition at line 17 of file BinomialInterval.h.

Member Enumeration Documentation

Constructor & Destructor Documentation

virtual BinomialInterval::~BinomialInterval ( )
virtualdefault

Member Function Documentation

double BinomialInterval::alpha ( void  ) const
inline

Definition at line 77 of file BinomialInterval.h.

References alpha_.

Referenced by init().

77 { return alpha_; }
virtual void BinomialInterval::calculate ( const double  successes,
const double  trials 
)
pure virtual
bool BinomialInterval::contains ( double  rho)

Definition at line 22 of file BinomialInterval.cc.

References lower_, lower_tailed, type_, upper_, and upper_tailed.

Referenced by coverage_prob().

22  {
23  if (type_ == upper_tailed)
24  return p <= upper_;
25  else if (type_ == lower_tailed)
26  return p >= lower_;
27  else //if (type_ == equal_tailed)
28  return p >= lower_ && p <= upper_;
29 }
double BinomialInterval::coverage_prob ( const double  rho,
const int  trials 
)

Definition at line 31 of file BinomialInterval.cc.

References calculate(), contains(), TtFullHadEvtBuilder_cfi::prob, and X.

Referenced by scan_ntot(), and scan_rho().

31  {
32  double prob = 0;
33 
34  for (int X = 0; X <= trials; ++X) {
35  calculate(X, trials);
36 
37  if (contains(p))
38  prob += ROOT::Math::binomial_pdf(X, p, trials);
39  }
40 
41  return prob;
42 }
virtual void calculate(const double successes, const double trials)=0
#define X(str)
Definition: MuonsGrabber.cc:38
bool contains(double rho)
void BinomialInterval::dump ( const int  trials_min,
const int  trials_max 
)

Definition at line 59 of file BinomialInterval.cc.

References calculate(), personalPlayback::fn, lower_, dqmiodumpmetadata::n, name(), AlCaHLTBitMon_QueryRunRegistry::string, upper_, and X.

Referenced by neyman().

59  {
60  const std::string fn = std::string("table.") + name() + std::string(".txt");
61  FILE* fdump = fopen(fn.c_str(), "wt");
62 
63  for (int n = trials_min; n <= trials_max; ++n) {
64  for (int X = 0; X <= n; X++) {
65  calculate(X, n);
66  fprintf(fdump, "%i %i %f %f\n", X, n, lower_, upper_);
67  }
68  fprintf(fdump, "\n");
69  }
70 
71  fclose(fdump);
72 }
virtual const char * name() const =0
virtual void calculate(const double successes, const double trials)=0
#define X(str)
Definition: MuonsGrabber.cc:38
void BinomialInterval::init ( const double  alpha,
const tail_type  t = equal_tailed 
)

Definition at line 14 of file BinomialInterval.cc.

References alpha(), alpha_, alpha_min_, equal_tailed, kappa2_, kappa_, and type_.

14  {
15  alpha_ = alpha;
16  type_ = type;
18  kappa_ = ROOT::Math::normal_quantile(1 - alpha / 2, 1);
19  kappa2_ = kappa_ * kappa_;
20 }
type
Definition: HCALResponse.h:21
double alpha() const
double BinomialInterval::length ( ) const
inline

Definition at line 80 of file BinomialInterval.h.

References lower_, and upper_.

80 { return upper_ - lower_; }
double BinomialInterval::lower ( ) const
inline

Definition at line 78 of file BinomialInterval.h.

References lower_.

78 { return lower_; }
virtual const char* BinomialInterval::name ( ) const
pure virtual
virtual bool BinomialInterval::neyman ( const int  ntot,
const int  nrho,
double *  rho,
double *  x_l,
double *  x_r 
)
inlinevirtual
void BinomialInterval::scan_ntot ( const double  rho,
const int  ntot_min,
const int  ntot_max,
double *  ntot,
double *  prob 
)

Definition at line 51 of file BinomialInterval.cc.

References coverage_prob(), mps_fire::i, and nt.

51  {
52  for (int i = 0; i < ntot_max - ntot_min + 1; ++i) {
53  int nt = i + ntot_min;
54  ntot[i] = nt;
55  prob[i] = coverage_prob(rho, nt);
56  }
57 }
int nt
Definition: AMPTWrapper.h:42
double coverage_prob(const double rho, const int trials)
void BinomialInterval::scan_rho ( const int  ntot,
const int  nrho,
double *  rho,
double *  prob 
)

Definition at line 44 of file BinomialInterval.cc.

References coverage_prob(), and mps_fire::i.

44  {
45  for (int i = 0; i < nrho; ++i) {
46  rho[i] = double(i) / nrho;
47  prob[i] = coverage_prob(rho[i], ntot);
48  }
49 }
double coverage_prob(const double rho, const int trials)
void BinomialInterval::set ( double  l,
double  u 
)
inlineprotected

Definition at line 92 of file BinomialInterval.h.

References cmsLHEtoEOSManager::l.

92  {
93  lower_ = l;
94  upper_ = u;
95  }
double BinomialInterval::upper ( ) const
inline

Definition at line 79 of file BinomialInterval.h.

References upper_.

79 { return upper_; }

Member Data Documentation

double BinomialInterval::alpha_
protected
double BinomialInterval::alpha_min_
protected

Definition at line 85 of file BinomialInterval.h.

Referenced by ClopperPearsonBinomialInterval::calculate(), and init().

double BinomialInterval::kappa2_
protected

Definition at line 87 of file BinomialInterval.h.

Referenced by init().

double BinomialInterval::kappa_
protected

Definition at line 86 of file BinomialInterval.h.

Referenced by init().

double BinomialInterval::lower_
protected
tail_type BinomialInterval::type_
protected
double BinomialInterval::upper_
protected