G01 Chapter Contents
G01 Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentG01BKF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

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

## 2  Specification

 SUBROUTINE G01BKF ( RLAMDA, K, PLEK, PGTK, PEQK, IFAIL)
 INTEGER K, IFAIL REAL (KIND=nag_wp) RLAMDA, PLEK, PGTK, PEQK

## 3  Description

Let $X$ denote a random variable having a Poisson distribution with parameter $\lambda$ $\left(>0\right)$. Then
 $ProbX=k=e-λλkk! , k=0,1,2,…$
The mean and variance of the distribution are both equal to $\lambda$.
G01BKF computes for given $\lambda$ and $k$ the probabilities:
 $PLEK=ProbX≤k PGTK=ProbX>k PEQK=ProbX=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  Parameters

1:     RLAMDA – REAL (KIND=nag_wp)Input
On entry: the parameter $\lambda$ of the Poisson distribution.
Constraint: $0.0<{\mathbf{RLAMDA}}\le {10}^{6}$.
2:     K – INTEGERInput
On entry: the integer $k$ which defines the required probabilities.
Constraint: ${\mathbf{K}}\ge 0$.
3:     PLEK – REAL (KIND=nag_wp)Output
On exit: the lower tail probability, $\mathrm{Prob}\left\{X\le k\right\}$.
4:     PGTK – REAL (KIND=nag_wp)Output
On exit: the upper tail probability, $\mathrm{Prob}\left\{X>k\right\}$.
5:     PEQK – REAL (KIND=nag_wp)Output
On exit: the point probability, $\mathrm{Prob}\left\{X=k\right\}$.
6:     IFAIL – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\mathbf{IFAIL}}=1$
 On entry, ${\mathbf{RLAMDA}}\le 0.0$.
${\mathbf{IFAIL}}=2$
 On entry, ${\mathbf{K}}<0$.
${\mathbf{IFAIL}}=3$
 On entry, ${\mathbf{RLAMDA}}>{10}^{6}$.

## 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).

The time taken by G01BKF depends on $\lambda$ and $k$. For given $\lambda$, the time is greatest when $k\approx \lambda$, and is then approximately proportional to $\sqrt{\lambda }$.

## 9  Example

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

### 9.1  Program Text

Program Text (g01bkfe.f90)

### 9.2  Program Data

Program Data (g01bkfe.d)

### 9.3  Program Results

Program Results (g01bkfe.r)