×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

#### Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
To Your Posts
• Keyword Search
• One-Click Access To Your
Favorite Forums
• Automated Signatures
On Your Posts
• Best Of All, It's Free!
• Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

# inverse poisson using perl (Math::CDF)

 Forum Search FAQs Links MVPs

## inverse poisson using perl (Math::CDF)

(OP)
Hi,

I'm work on probabilities and I'm looking for a perl module that mimics the excel POISSON(x,mean,cumulative) function where cumulative = False.

The only module I have come across that is close is the Math::CDF distribution however by default the this works with cumulative probabilities which unfortunately for my purpose is no good.

I would be interested to know if anyone has came across this scenario before or has any useful tips or pointers?

Thanks
spperl

### RE: inverse poisson using perl (Math::CDF)

Though this is not at all efficient, you can calculate the local value from two cumulatives: POISSON(x,mean,TRUE)-POISSON(x-1,mean,TRUE).
However the POISSON function is quite simple to code: in the module Math::BigFloat you have the factorial function, if you need to use big numbers, otherwise that's quite simple to code (untested).

#### CODE -->

sub Poisson{
my($x,$mu)=@_;
return exp(-$x)*$mu**$x/fact($x);
}
sub fact{
my($n)=@_; my($p,$i);$p=1;
for($i=2;$i<=$n;$i++){$p*=$i}
return$p; } }  Of course this doesn't account for overflow conditions. If you know in advance your upper limits on$x and $mu you can code them as error tests into the functions. Also note that this code will return an answer also if$x is not integer, however the result wouldn't be correct: you should test that \$x is integer and positive.

http://www.xcalcs.com : Online engineering calculations
http://www.megamag.it : Magnetic brakes for fun rides
http://www.levitans.com : Air bearing pads

### RE: inverse poisson using perl (Math::CDF)

(OP)
Hi,

Thanks for your reply and taking the time to do this. I did end up coding manually.

So thanks again!

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

### Reply To This Thread

#### Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!

Already a member? Close this window and log in.