Poisson distribution for a given mean

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!

Some ideas:

1 Like

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();

//Same with mean at 50:
mean = 50.;
auto data2 = pois.generate(x, 100);
pois.plotOn(frame, RooFit::LineColor(kRed));
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.