# Problem Generating Poisson Histograms with Large Means

Hello all,

I am trying to generate and fit poisson distributions with varying mean values. I am able to do this sucessfully for distributions with low mean values (0-125). However, when I want to do this for larger values which require me to set the TF1 binmax parameter to 147 or larger all my enteries occur in the last bin only. I am using ROOT Pro version 3.10/02 on Windows ME. My code is as below:

``````// Poisson Distribution
Double_t func(Double_t *x,Double_t *par)
{
Double_t xx=x[0];
if (xx<=0) return 0;
return par[0]*TMath::Power(par[1],xx)/TMath::Gamm(xx+1)/TMath::Exp(par[1]);
}

void poisson()
{
gROOT->Reset();

// Poisson TF1
TF1 *pois = new TF1("pois",func,0,10,2); // x in [0;10], 2 parameters
pois->SetNpx(2000);
pois->SetParName(0,"Const");
pois->SetParName(1,"#mu");

// Create histogram with poisson distribution
TH1F *testhi = new TH1F("testhi","Poisson distribution",70,77,147);
pois->SetParameter(0,500.75654);
pois->SetParameter(1,125.45623);
testhi->FillRandom("pois",20000);

// Set initial fit paramters
pois->SetParameter(0,400.0);
pois->SetParameter(1,121.0);

// Create canvas
TCanvas *cc = new TCanva ("cc","Canvas",600,600);
gStyle->SetOptStat(0);
gStyle->SetOptFit(111);
gStyle->SetOptStat("nemrou");

// Fit Poisson and draw histogram
testhi->Fit("pois");
testhi->Draw();
}``````

If anyone can see my error then I would appreciate the help.
Cheers, Andrew

Your set of parameters generates infinities. eg
TMath::Power(125.45,146.9) > 1e309
TMath::Gamma(148)=1.7e256

You cannot save x > 146.9 with your settings

Why donâ€™t you use a gaussian instead ?

Rene