NAG FL Interface
g01bkf (prob_​poisson)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

g01bkf returns the lower tail, upper tail and point probabilities associated with a Poisson distribution.

2 Specification

Fortran Interface
Subroutine g01bkf ( rlamda, k, plek, pgtk, peqk, ifail)
Integer, Intent (In) :: k
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: rlamda
Real (Kind=nag_wp), Intent (Out) :: plek, pgtk, peqk
C Header Interface
#include <nag.h>
void  g01bkf_ (const double *rlamda, const Integer *k, double *plek, double *pgtk, double *peqk, Integer *ifail)
The routine may be called by the names g01bkf or nagf_stat_prob_poisson.

3 Description

Let X denote a random variable having a Poisson distribution with parameter λ (>0). Then
Prob{X=k}=e-λλkk! ,  k=0,1,2,  
The mean and variance of the distribution are both equal to λ.
g01bkf computes for given λ and k the probabilities:
plek=Prob{Xk} pgtk=Prob{X>k} peqk=Prob{X=k} .  
The method is described in Knüsel (1986).

4 References

Knüsel L (1986) Computation of the chi-square and Poisson distribution SIAM J. Sci. Statist. Comput. 7 1022–1036

5 Arguments

1: rlamda Real (Kind=nag_wp) Input
On entry: the parameter λ of the Poisson distribution.
Constraint: 0.0<rlamda106.
2: k Integer Input
On entry: the integer k which defines the required probabilities.
Constraint: k0.
3: plek Real (Kind=nag_wp) Output
On exit: the lower tail probability, Prob{Xk}.
4: pgtk Real (Kind=nag_wp) Output
On exit: the upper tail probability, Prob{X>k}.
5: peqk Real (Kind=nag_wp) Output
On exit: the point probability, Prob{X=k}.
6: ifail Integer Input/Output
On entry: ifail must be set to 0, −1 or 1 to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of 0 causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of −1 means that an error message is printed while a value of 1 means that it is not.
If halting is not appropriate, the value −1 or 1 is recommended. If message printing is undesirable, then the value 1 is recommended. Otherwise, the value 0 is recommended. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6 Error Indicators and Warnings

If on entry ifail=0 or −1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, rlamda=value.
Constraint: rlamda>0.0.
ifail=2
On entry, k=value.
Constraint: k0.
ifail=3
On entry, rlamda=value.
Constraint: rlamda106.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

7 Accuracy

Results are correct to a relative accuracy of at least 10−6 on machines with a precision of 9 or more decimal digits, and to a relative accuracy of at least 10−3 on machines of lower precision (provided that the results do not underflow to zero).

8 Parallelism and Performance

g01bkf is not threaded in any implementation.

9 Further Comments

The time taken by g01bkf depends on λ and k. For given λ, the time is greatest when kλ, and is then approximately proportional to λ.

10 Example

This example reads values of λ and k from a data file until end-of-file is reached, and prints the corresponding probabilities.

10.1 Program Text

Program Text (g01bkfe.f90)

10.2 Program Data

Program Data (g01bkfe.d)

10.3 Program Results

Program Results (g01bkfe.r)