Dear Rooters,
I’m trying to generate a binomial pdf which I can then fit to my measured data. Problem is RooFit doesn’t seem to be able to compute the pdf in discrete integer steps, or to put it another way it has no functionality to allow the user to declare an integer variable, with RooRealVar() implicitly computing the pdf in arbitrary non-integer steps.
Using RooRealVar("","",RooConst(x),RooConst(x1),RooConst(x2)) gives error message …"candidate constructor not viable…
Using RooConstVar() gives similar message.
Is there a workaround? I posted a similar question on the “Stat and Math Tool Support” a few days ago but have had no takers ! perhaps I might have better joy here
!
Many many thanks in advance!
see example of code and output below
#ifndef __CINT__
#include "RooGlobalFunc.h"
#endif
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "TMath.h"
#include "TCanvas.h"
#include "RooPlot.h"
#include "TAxis.h"
using namespace RooFit ;
void FitGeneratedBinomialModelToData()
{
// Declare variables
RooRealVar p("p","p",0.5,0,1) ;
RooRealVar smalln("smalln","smalln",1,0,50) ;
RooRealVar bigN("bigN","bigN",40,39,41) ;
// build pdf
RooGenericPdf binomialpdf("binomial","binomial PDF","pow(p,smalln)*pow((1-p),(bigN-smalln))*TMath::Factorial(bigN)/(TMath::Factorial(smalln)*TMath::Factorial(bigN-smalln))",RooArgSet(smalln,p,bigN)) ;
// Construct plot frame in 'm'
RooPlot* xframe = smalln.frame(Title("Generated binomial p.d.f.")) ;
// Plot
binomialpdf.plotOn(xframe) ;
// Draw all frames on a canvas
TCanvas* c = new TCanvas("binomialPdf","binomialPdf",400,400) ;
gPad->SetLeftMargin(0.15) ; xframe->GetYaxis()->SetTitleOffset(1.6) ; xframe->Draw() ;
}
******************************
Output:
[attachment=0]binomialPdf.png[/attachment]