Jump to content

Calculate poisson probability percentage in php


runnerjp

Recommended Posts

I'm going to copy/paste from the source:

/**********************************************************************
       Cumulative Distribution Function POIsson distribution
                              Function
     Calculates any one parameter of the Poisson
     distribution given values for the others.
                              Arguments
     WHICH --> Integer indicating which  argument
               value is to be calculated from the others.
               Legal range: 1..3
               iwhich = 1 : Calculate P and Q from S and XLAM
               iwhich = 2 : Calculate A from P,Q and XLAM
               iwhich = 3 : Calculate XLAM from P,Q and S
        P <--> The cumulation from 0 to S of the poisson density.
               Input range: [0,1].
        Q <--> 1-P.
               Input range: (0, 1].
               P + Q = 1.0.
        S <--> Upper limit of cumulation of the Poisson.
               Input range: [0, +infinity).
               Search range: [0,1E100]
     XLAM <--> Mean of the Poisson distribution.
               Input range: [0, +infinity).
               Search range: [0,1E100]
     STATUS <-- 0 if calculation completed correctly
               -I if input parameter number I is out of range
                1 if answer appears to be lower than lowest
                  search bound
                2 if answer appears to be higher than greatest
                  search bound
                3 if P + Q .ne. 1
     BOUND <-- Undefined if STATUS is 0
               Bound exceeded by parameter number I if STATUS
               is negative.
               Lower search bound if STATUS is 1.
               Upper search bound if STATUS is 2.
                              Method
     Formula   26.4.21  of   Abramowitz  and   Stegun,   Handbook  of
     Mathematical Functions (1966) is used  to reduce the computation
     of  the cumulative distribution function to that  of computing a
     chi-square, hence an incomplete gamma function.
     Cumulative  distribution function  (P) is  calculated  directly.
     Computation of other parameters involve a seach for a value that
     produces  the desired value of  P.   The  search relies  on  the
     monotinicity of P with the other parameter.
**********************************************************************/
If $which == 1,

- $par1 is the S value

- $par2 is the XLAM value

If $which == 2,

- $par1 is the P value (and Q is 1-P)

- $par2 is the XLAM value

If $which == 3,

- $par1 is the S value

- $par2 is the P value (and Q is 1-P)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.