Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_stat_prob_poisson (g01bk)

## Purpose

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

## Syntax

[plek, pgtk, peqk, ifail] = g01bk(rlamda, k)
[plek, pgtk, peqk, ifail] = nag_stat_prob_poisson(rlamda, k)

## 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_stat_prob_poisson (g01bk) 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).

## References

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

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{rlamda}$ – double scalar
The parameter $\lambda$ of the Poisson distribution.
Constraint: $0.0<{\mathbf{rlamda}}\le {10}^{6}$.
2:     $\mathrm{k}$int64int32nag_int scalar
The integer $k$ which defines the required probabilities.
Constraint: ${\mathbf{k}}\ge 0$.

None.

### Output Parameters

1:     $\mathrm{plek}$ – double scalar
The lower tail probability, $\mathrm{Prob}\left\{X\le k\right\}$.
2:     $\mathrm{pgtk}$ – double scalar
The upper tail probability, $\mathrm{Prob}\left\{X>k\right\}$.
3:     $\mathrm{peqk}$ – double scalar
The point probability, $\mathrm{Prob}\left\{X=k\right\}$.
4:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\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}$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## 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_stat_prob_poisson (g01bk) depends on $\lambda$ and $k$. For given $\lambda$, the time is greatest when $k\approx \lambda$, and is then approximately proportional to $\sqrt{\lambda }$.

## Example

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

fprintf('g01bk example results\n\n');

rlamda =    [0.75  9.2  34  175];
k = int64([3     12   25  175]);

fprintf('  rlamda     k     plek      pgtk      peqk\n');
for i=1:4
[plek, pgtk, peqk, ifail] = ...
g01bk(rlamda(i), k(i));

fprintf('%8.3f%6d%10.5f%10.5f%10.5f\n', rlamda(i), k(i), plek, pgtk, peqk);
end

```
```g01bk example results

rlamda     k     plek      pgtk      peqk
0.750     3   0.99271   0.00729   0.03321
9.200    12   0.86074   0.13926   0.07755
34.000    25   0.06736   0.93264   0.02140
175.000   175   0.52009   0.47991   0.03014
```