This is the mail archive of the
gsl-discuss@sourceware.org
mailing list for the GSL project.
Re: request for Poisson CDF inverse
- From: shd at jolt dot modeemi dot cs dot tut dot fi (Heikki Orsila)
- To: Jason Detwiler <jasondet at gmail dot com>
- Cc: gsl-discuss at sources dot redhat dot com
- Date: Fri, 6 Jul 2007 12:30:03 +0300
- Subject: Re: request for Poisson CDF inverse
- References: <b1d795290707051716s4f4d00e5jeabec36855569558@mail.gmail.com>
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