CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BinomialInterval.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_RooStatsCms_BinomialInterval_h
2 #define PhysicsTools_RooStatsCms_BinomialInterval_h
3 /* \class BinomialInterval
4  *
5  * \author Jordan Tucker
6  * integration in CMSSW: Luca Lista
7  *
8  */
9 
10 
11 #if (defined (STANDALONE) or defined (__CINT__) )
12 #include "TNamed.h"
13 #endif
14 
15 // A class to implement the calculation of intervals for the binomial
16 // parameter rho. The bulk of the work is done by derived classes that
17 // implement calculate() appropriately.
19 #if (defined (STANDALONE) or defined (__CINT__) )
20 : public TNamed
21 #endif
22 {
23 public:
24  // For central intervals, an enum to indicate whether the interval
25  // should put all of alpha at the lower or upper end, or equally
26  // divide it.
28 
29  // Set alpha, type, and the cached values of kappa (the normal
30  // quantile).
31  void init(const double alpha, const tail_type t=equal_tailed);
32 
33  // Methods which derived classes must implement.
34 
35  // Calculate the interval given a number of successes and a number
36  // of trials. (Successes/trials are doubles to having to cast to
37  // double later anyway.)
38  virtual void calculate(const double successes, const double trials) = 0;
39 
40  // Return a pretty name for the interval (e.g. "Feldman-Cousins").
41  virtual const char* name() const = 0;
42 
43  // A simple test (depending on the tail type) whether a certain
44  // value of the binomial parameter rho is in the interval or not.
45  bool contains(double rho);
46 
47  // Calculate and return the coverage probability given the true
48  // binomial parameter rho and the number of trials.
49  double coverage_prob(const double rho, const int trials);
50 
51  // Convenience methods to scan the parameter space. In each, the
52  // pointers must point to already-allocated arrays of double, with
53  // the number of doubles depending on the method. (double is used
54  // even for parameters that are naturally int for compatibility with
55  // TGraph/etc.)
56 
57  // Given ntot trials, scan rho in [0,1] with nrho points (so the
58  // arrays must be allocated double[nrho]).
59  void scan_rho(const int ntot, const int nrho, double* rho, double* prob);
60 
61  // Given the true value of rho, scan over from ntot_min to ntot_max
62  // trials (so the arrays must be allocated double[ntot_max -
63  // ntot_min + 1]).
64  void scan_ntot(const double rho, const int ntot_min, const int ntot_max, double* ntot, double* prob);
65 
66  // Construct nrho acceptance sets in rho = [0,1] given ntot trials
67  // and put the results in x_l and x_r. The arrays must be allocated
68  // as double[nrho].
69  virtual bool neyman(const int ntot, const int nrho, double* rho, double* x_l, double* x_r) { return false; }
70 
71  // Dump a table of intervals from trials_min to trials_max, with
72  // successes = 0 to trials for each. The table is produced in a file
73  // in the current directory, given the name of the interval.
74  void dump(const int trials_min, const int trials_max);
75 
76  // Simple accessors.
77  double alpha() const { return alpha_; }
78  double lower() const { return lower_; }
79  double upper() const { return upper_; }
80  double length() const { return upper_ - lower_; }
81 
82 protected:
83  double alpha_;
85  double alpha_min_;
86  double kappa_;
87  double kappa2_;
88 
89  double lower_;
90  double upper_;
91 
92  void set(double l, double u) { lower_ = l; upper_ = u; }
93 
94 #if (defined (STANDALONE) or defined (__CINT__) )
95 ClassDef(BinomialInterval,1)
96 #endif
97 };
98 
99 #endif
100 
#define STANDALONE
tuple t
Definition: tree.py:139
virtual bool neyman(const int ntot, const int nrho, double *rho, double *x_l, double *x_r)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
double upper() const
virtual void calculate(const double successes, const double trials)=0
double alpha() const
virtual const char * name() const =0
void init(const double alpha, const tail_type t=equal_tailed)
void scan_rho(const int ntot, const int nrho, double *rho, double *prob)
void set(double l, double u)
double lower() const
double coverage_prob(const double rho, const int trials)
double length() const
bool contains(double rho)
if(conf.exists("allCellsPositionCalc"))
void scan_ntot(const double rho, const int ntot_min, const int ntot_max, double *ntot, double *prob)
void dump(const int trials_min, const int trials_max)