XL: ATP Definition: POISSONID: Q87862 
  | 
The versions of Microsoft Excel listed at the beginning of this article
provide a set of special analysis tools called the Analysis ToolPak. This
article is part of a series of articles that provides information about
the underlying formulas used in the Analysis ToolPak functions.
This article covers the following function:
   POISSON(x,mean,cumulative) 
The POISSON function returns the result of the Poisson probability
distribution function for a particular value of the random variable X.
It follows the form "Poisson(x,mean,cumulative)", where:
   x = number of events
   mean = expected value or average of the distribution
   cumulative = logical value specifying whether to return the cumulative
   distribution or the probability mass function. 
   #include  <math.h>
   #define PI 3.141592654
   float poidev(xm,idum)
   float xm;
   int *idum;
   {
           static float sq,alxm,g,oldm=(-1.0)
           float em,t,y;
           float ran1(),gammln();
           if (xm < 12.0) {
                   if (xm != oldm) {
                           oldm=xm;
                           g=exp(-xm);
                   }
                   em = -1;
                   t = 1.0;
                   do {
                           em += 1.0;
                           t *= ran1(idum);
                   } while (t > g);
           } else {
                   if (xm != oldm) {
                           oldm=xm;
                           sq=sqrt(2.0*xm);
                           alxm=log(xm);
                           g=xm*alxm-gammln(xm+1.0);
                   }
                   do {
                           do {
                                   y=tan(PI*ran1(idum));
                                   em=sq*y*xm;
                           } while (em < 0.0);
                           em=floor(em);
                           t=0.9*(1.0+y*y)*exp(em*alxm-gammln(em+1.0)-g);
                   } while ran1(idum) < t);
           }
           return em;
   } 
"Numerical Recipes in C," Press, Flannery et al, pages 218-222
"Microsoft Excel Function Reference," version 4.0, pages 328-329
Additional query words: XL98 XL97 XL7 XL5 XL4 98 97 atp tool pak pack
Keywords          : 
Version           : WINDOWS:4.0,5.0,7.0,97; MACINTOSH:4.0,5.0,98
Platform          : MACINTOSH WINDOWS 
Issue type        : 
Last Reviewed: August 3, 1999