Hi Michele,
A Poisson distribution is for counting some sort of event. If you just need the output to be floats for technical reasons you can recast it. If you need to simulate measurements of a continuous distribution then maybe you should consider a more appropriate pdf?
Cheers, Alex
On Mar 16, 2012, at 2:14 PM, Vassili Maroussov wrote:
> Alternatively, you can use the UNURAN package: > > Double_t PoissonReal(const Double_t *k, const Double_t *lambda) { > return TMath::Exp(k[0]*TMath::Log(lambda[0])-lambda[0]) / TMath::Gamma(k[0]+1.); > } > > TF1 MyPoisson = new TF1("MyPoisson", PoissonReal,0.,MaxPoissArg,1) > > TUnuran u; > > u.Init(TUnuranDistrCont(MyPoisson)); > > X = u.Sample(); > > On 03/16/2012 01:56 PM, Vassili Maroussov wrote:
>>> >>> Dear ROOT experts, >>> >>> I am trying to generate random numbers according to a poisson distribution. I need non integer values. I thought the PoissonD method does the job, but i seem do get only int as an output. >>> >>> TRandom *rd = new TRandom(); >>> cout<<rd->Poisson(5)<<endl; >>> >>> I get as expected an integer, but if I do >>> >>> cout<<rd->PoissonD(5)<<endl; >>> >>> then I also get an integer.. Maybe I am using the wrong method? Isn't the continuous version of a poissonian still called a poissonian? >>> >>> Thanks >>> >>> Michele
This archive was generated by hypermail 2.2.0 : Mon Mar 19 2012 - 11:50:02 CET