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 
10 #include "Math/PdfFuncMathCore.h"
11 
12 #include <cmath>
13 
15 public:
16  BinomialProbHelper(double rho, int x, int n)
17  : rho_(rho), x_(x), n_(n),
18  rho_hat_(double(x)/n),
19  prob_(ROOT::Math::binomial_pdf(x, rho, n)) {
20  // Cache the likelihood ratio L(\rho)/L(\hat{\rho}), too.
21  if (x == 0)
22  lratio_ = pow(1 - rho, n);
23  else if (x == n)
24  lratio_ = pow(rho, n);
25  else
26  lratio_ = pow(rho/rho_hat_, x) * pow((1 - rho)/(1 - rho_hat_), n - x);
27  }
28 
29  double rho () const { return rho_; };
30  int x () const { return x_; };
31  int n () const { return n_; };
32  double prob () const { return prob_; };
33  double lratio() const { return lratio_; };
34 
35  private:
36  double rho_;
37  int x_;
38  int n_;
39  double rho_hat_;
40  double prob_;
41  double lratio_;
42 };
43 
44 #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