Go to the documentation of this file.00001 #ifndef PhysicsTools_RooStatsCms_BinomialProbHelper_h
00002 #define PhysicsTools_RooStatsCms_BinomialProbHelper_h
00003
00004
00005
00006
00007
00008
00009
00010 class BinomialProbHelper {
00011 public:
00012 BinomialProbHelper(double rho, int x, int n)
00013 : rho_(rho), x_(x), n_(n),
00014 rho_hat_(double(x)/n),
00015 prob_(ROOT::Math::binomial_pdf(x, rho, n)) {
00016
00017 if (x == 0)
00018 lratio_ = pow(1 - rho, n);
00019 else if (x == n)
00020 lratio_ = pow(rho, n);
00021 else
00022 lratio_ = pow(rho/rho_hat_, x) * pow((1 - rho)/(1 - rho_hat_), n - x);
00023 }
00024
00025 double rho () const { return rho_; };
00026 int x () const { return x_; };
00027 int n () const { return n_; };
00028 double prob () const { return prob_; };
00029 double lratio() const { return lratio_; };
00030
00031 private:
00032 double rho_;
00033 int x_;
00034 int n_;
00035 double rho_hat_;
00036 double prob_;
00037 double lratio_;
00038 };
00039
00040 #endif