Dear Experts,
Please help me in getting the poisson distribution for a given mean for a given number of iteration, and to to plot them as a histogram.
Thank you!
Dear Experts,
Please help me in getting the poisson distribution for a given mean for a given number of iteration, and to to plot them as a histogram.
Thank you!
Since you asked in the RooFit forum, here is how you would do it:
unsigned int upperEnd = 100;
RooRealVar x("x", "x", 0, upperEnd);
//We use a custom binning to make all bins start at integer values. Otherwise, the plot might look a bit odd
x.setBinning(RooUniformBinning(0, upperEnd, upperEnd));
//Set mean to 5.
RooRealVar mean("mean", "mean", 5., 0, 100);
RooPoisson pois("Poisson", "Poisson", x, mean);
auto data = pois.generate(x, 100);
auto frame = x.frame();
data->plotOn(frame);
pois.plotOn(frame);
frame->Draw();
//Same with mean at 50:
mean = 50.;
auto data2 = pois.generate(x, 100);
data2->plotOn(frame);
pois.plotOn(frame, RooFit::LineColor(kRed));
frame->Draw();
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.