Re: [ROOT] poisson question

From: Stanislav Nesterov (Stanislav.Nesterov@pnpi.spb.ru)
Date: Tue Dec 02 2003 - 14:44:44 MET


 Hi Dan,
 I must say, that both of  the results are incorrect, but you are trying 
to integrate Poisson distribution instead of making the sum. In ROOT the 
Poisson PDF is implemented by means of Euler's Gamma-function (for the 
factorial), so for all integer arguments it is correct. BUT for 
non-integer values it IS NOT equal to the Poisson distribution. You'd 
rather have to re-implement it to be non-smooth function or don't 
integrate, but sum it.

 I can propose the function like this, and I hope Rene will include it 
in TMath:

Double_t TMath::Poisson(Double_t x, Double_t par)
{
  // compute the Poisson distribution function for (x,par)

#define MaxInt 2e6  // <-- this can be other constant
     if(x<0) return 0;
     if(x<1) return TMath::Exp(-par);
     Double_t gam;
     if(x<MaxInt) gam = 
TMath::Power(par,Int_t(x))/TMath::Gamma(Int_t(x)+1); else
                            gam = TMath::Power(par,x)/TMath::Gamma(x+1);
     return gam/TMath::Exp(par);

}

                            Best regards,
                                                       Stanislav.



Dan Holmes wrote:

>Hi,
>
>i kind of asked this question a week and a half ago but i got no responce 
>so i will try again..
>
>root vers: 3.05/07
>
>To what accuracy can i use the poisson function?
>
>I do:
>poiss1=new TF1("poiss1","TMath::Poisson(x,[1])",0,99);
>
>float x0=3;
>poiss1->SetParameter(1,x0);
>poiss1.Integral(0,99) 
>
>  
>
>>>9.82143583403792597e-01
>>>      
>>>
>
>float x0=0.3;
>poiss1->SetParameter(1,x0);
>poiss1.Integral(0,99)
>
>  
>
>>>5.85493726744197751e-01
>>>      
>>>
>
>..i guess the first case is accurate to at least a few percent? ..how 
>about the second case? ..what is the lower limit to which i can set x0 and 
>still get a reasonable answer?
>
>cheers,
>
>Dan.
>
>
>
>  
>



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:17 MET