Fitting a histogram with an integer function

Hi, forum

I’m trying to fit a histogram with a Poisson distribution function.
Ok, It’s easy to create the probability mass function for Poisson distribution, but how can I use it for fitting?

Thank You in advance.

see example below


[code]void poiss()
TRandom3 r;
TH1F *h1 = new TH1F(“h1”,“Poisson distribution”,20,0,20);
for (Int_t i=0;i<1000>Fill(r.Poisson(7));

// Creates a Root function based on TMath::Poisson function
TF1 *func = new TF1(“poisson”,"[0]*TMath::Poisson(x,[1])",0,20);

// Sets initial values and parameter names

// Fit histogram in range defined by function

Thanks, it fits well.

But I’m kind of confused. It looks like this TF1 function is continuous.

You can use TMath::PoissonI instead