This is the mail archive of the gsl-discuss@sourceware.org mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: request for Poisson CDF inverse


On Thu, Jul 05, 2007 at 05:16:38PM -0700, Jason Detwiler wrote:
> I am looking to calculate the inverse of the CDF for the Poisson
> distribution. I noticed that many of the CDFs coded in gsl have
> inverse functions also coded, but this is not the case for the Poisson
> distribution (unfortunately for me). I would like to "request" these
> functions. I would try to contribute them myself, but I'm not
> confident I could code them to the standards of gsl. What are the
> chances of my wishes being fulfilled by another developer?

Are you looking for something like this?

	http://zakalwe.fi/~shd/code/poisson.py

This code maps a probability from range [0, 1) into a number of 
random events happening at a given invocation. This is done in 
Poisson_Process.random().

Example, 1E6 invocations, probability p = 0.05 of an event. This will 
give frequencies for each N (the number of random events happening):

$ ./poisson.py |sort -n |uniq -c |sort -n
...
     75 3
   2482 2
  47754 1
 949688 0

As a comparison:
	1E6*0.05^1 = 50000
	1E6*0.05^2 = 2500
	1E6*0.05^3 = 125

So these values are pretty close to what they should be. This random 
process is only an approximation. I put an intentional limit into 
probabilities so that events that rarer than 1E-9 do not happen unless 
the Poisson_Process constructor is suplied with a value.

-- 
Heikki Orsila			Barbie's law:
heikki.orsila@iki.fi		"Math is hard, let's go shopping!"
http://www.iki.fi/shd


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]