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