g01 Chapter Contents
g01 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_poisson_dist (g01bkc)

## 1  Purpose

nag_poisson_dist (g01bkc) returns the lower tail, upper tail and point probabilities associated with a Poisson distribution.

## 2  Specification

 #include #include
 void nag_poisson_dist (double rlamda, Integer k, double *plek, double *pgtk, double *peqk, NagError *fail)

## 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$.
nag_poisson_dist (g01bkc) 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  Arguments

On entry: the parameter $\lambda$ of the Poisson distribution.
Constraint: $0.0<{\mathbf{rlamda}}\le {10}^{6}$.
2:     kIntegerInput
On entry: the integer $k$ which defines the required probabilities.
Constraint: ${\mathbf{k}}\ge 0$.
3:     plekdouble *Output
On exit: the lower tail probability, $\mathrm{Prob}\left\{X\le k\right\}$.
4:     pgtkdouble *Output
On exit: the upper tail probability, $\mathrm{Prob}\left\{X>k\right\}$.
5:     peqkdouble *Output
On exit: the point probability, $\mathrm{Prob}\left\{X=k\right\}$.
6:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

## 6  Error Indicators and Warnings

On entry, argument $〈\mathit{\text{value}}〉$ had an illegal value.
NE_INT_ARG_LT
On entry, ${\mathbf{k}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{k}}\ge 0$.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
NE_REAL_ARG_GT
On entry, ${\mathbf{rlamda}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{rlamda}}\le {10}^{6}$.
NE_REAL_ARG_LE
On entry, ${\mathbf{rlamda}}=〈\mathit{\text{value}}〉$.
Constraint: ${\mathbf{rlamda}}>0.0$.

## 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 nag_poisson_dist (g01bkc) 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 (g01bkce.c)

### 9.2  Program Data

Program Data (g01bkce.d)

### 9.3  Program Results

Program Results (g01bkce.r)