CMS 3D CMS Logo

BinomialProbHelper.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_RooStatsCms_BinomialProbHelper_h
2 #define PhysicsTools_RooStatsCms_BinomialProbHelper_h
3 /* \class BinomialProbHelper
4  *
5  * \author Jordan Tucker
6  * integration in CMSSW: Luca Lista
7  *
8  */
9 
11 public:
12  BinomialProbHelper(double rho, int x, int n)
13  : rho_(rho), x_(x), n_(n),
14  rho_hat_(double(x)/n),
15  prob_(ROOT::Math::binomial_pdf(x, rho, n)) {
16  // Cache the likelihood ratio L(\rho)/L(\hat{\rho}), too.
17  if (x == 0)
18  lratio_ = pow(1 - rho, n);
19  else if (x == n)
20  lratio_ = pow(rho, n);
21  else
22  lratio_ = pow(rho/rho_hat_, x) * pow((1 - rho)/(1 - rho_hat_), n - x);
23  }
24 
25  double rho () const { return rho_; };
26  int x () const { return x_; };
27  int n () const { return n_; };
28  double prob () const { return prob_; };
29  double lratio() const { return lratio_; };
30 
31  private:
32  double rho_;
33  int x_;
34  int n_;
35  double rho_hat_;
36  double prob_;
37  double lratio_;
38 };
39 
40 #endif
double rho() const
double prob() const
BinomialProbHelper(double rho, int x, int n)
double lratio() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40