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_univar_ci_poisson (g07ab)

## Purpose

nag_univar_ci_poisson (g07ab) computes a confidence interval for the mean parameter of the Poisson distribution.

## Syntax

[tl, tu, ifail] = g07ab(n, xmean, clevel)
[tl, tu, ifail] = nag_univar_ci_poisson(n, xmean, clevel)

## Description

Given a random sample of size n$n$, denoted by x1,x2,,xn${x}_{1},{x}_{2},\dots ,{x}_{n}$, from a Poisson distribution with probability function
 p(x) = e − θ(θx)/(x ! ),  x = 0,1,2, … $p(x)=e-θ θxx! , x=0,1,2,…$
the point estimate, θ̂$\stackrel{^}{\theta }$, for θ$\theta$ is the sample mean, x$\stackrel{-}{x}$.
Given n$n$ and x$\stackrel{-}{x}$ this function computes a 100(1α)%$100\left(1-\alpha \right)%$ confidence interval for the parameter θ$\theta$, denoted by [θl,θu${\theta }_{l},{\theta }_{u}$], where α$\alpha$ is in the interval (0,1)$\left(0,1\right)$.
The lower and upper confidence limits are estimated by the solutions to the equations
 ∞ e − nθl ∑ ((nθl)x)/(x ! ) = α/2, x = T
 T e − nθu ∑ ((nθu)x)/(x ! ) = α/2, x = 0
$e-nθl∑x=T∞ (nθl)xx! =α2, e-nθu∑x=0T(nθu)xx! =α2,$
where T = i = 1nxi = nθ̂$T=\sum _{i=1}^{n}{x}_{i}=n\stackrel{^}{\theta }$.
The relationship between the Poisson distribution and the χ2${\chi }^{2}$-distribution (see page 112 of Hastings and Peacock (1975)) is used to derive the equations
 θl = 1/(2n)χ2T,α / 22, θu = 1/(2n)χ2T + 2,1 − α / 22,
$θl= 12n χ2T,α/22, θu= 12n χ2T+2,1-α/22,$
where χν,p2${\chi }_{\nu ,p}^{2}$ is the deviate associated with the lower tail probability p$p$ of the χ2${\chi }^{2}$-distribution with ν$\nu$ degrees of freedom.
In turn the relationship between the χ2${\chi }^{2}$-distribution and the gamma distribution (see page 70 of Hastings and Peacock (1975)) yields the following equivalent equations;
 θl = 1/(2n)γT,2;α / 2, θu = 1/(2n)γT + 1,2;1 − α / 2,
$θl= 12n γT,2;α/2, θu= 12n γT+1,2;1-α/2,$
where γα,β;δ${\gamma }_{\alpha ,\beta \text{;}\delta }$ is the deviate associated with the lower tail probability, δ$\delta$, of the gamma distribution with shape parameter α$\alpha$ and scale parameter β$\beta$. These deviates are computed using nag_stat_inv_cdf_gamma (g01ff).

## References

Hastings N A J and Peacock J B (1975) Statistical Distributions Butterworth
Snedecor G W and Cochran W G (1967) Statistical Methods Iowa State University Press

## Parameters

### Compulsory Input Parameters

1:     n – int64int32nag_int scalar
n$n$, the sample size.
Constraint: n1${\mathbf{n}}\ge 1$.
2:     xmean – double scalar
The sample mean, x$\stackrel{-}{x}$.
Constraint: xmean0.0${\mathbf{xmean}}\ge 0.0$.
3:     clevel – double scalar
The confidence level, (1α)$\left(1-\alpha \right)$, for two-sided interval estimate. For example clevel = 0.95${\mathbf{clevel}}=0.95$ gives a 95%$95%$ confidence interval.
Constraint: 0.0 < clevel < 1.0$0.0<{\mathbf{clevel}}<1.0$.

None.

None.

### Output Parameters

1:     tl – double scalar
The lower limit, θl${\theta }_{l}$, of the confidence interval.
2:     tu – double scalar
The upper limit, θu${\theta }_{u}$, of the confidence interval.
3:     ifail – int64int32nag_int scalar
${\mathrm{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:
ifail = 1${\mathbf{ifail}}=1$
 On entry, n < 1${\mathbf{n}}<1$, or xmean < 0.0${\mathbf{xmean}}<0.0$, or clevel ≤ 0.0${\mathbf{clevel}}\le 0.0$, or clevel ≥ 1.0${\mathbf{clevel}}\ge 1.0$.
ifail = 2${\mathbf{ifail}}=2$
When using the relationship with the gamma distribution to calculate one of the confidence limits, the series to calculate the gamma probabilities has failed to converge. Both tl and tu are set to zero. This is a very unlikely error exit and if it occurs please contact NAG.

## Accuracy

For most cases the results should have a relative accuracy of max (0.5e12,50.0 × ε)$\mathrm{max}\phantom{\rule{0.125em}{0ex}}\left(\text{0.5e}-12,50.0×\epsilon \right)$ where ε$\epsilon$ is the machine precision (see nag_machine_precision (x02aj)). Thus on machines with sufficiently high precision the results should be accurate to 12$12$ significant digits. Some accuracy may be lost when α / 2$\alpha /2$ or 1α / 2$1-\alpha /2$ is very close to 0.0$0.0$, which will occur if clevel is very close to 1.0$1.0$. This should not affect the usual confidence intervals used.

None.

## Example

```function nag_univar_ci_poisson_example
n = int64(98);
xmean = 3.020408163265306;
clevel = 0.95;
[tl, tu, ifail] = nag_univar_ci_poisson(n, xmean, clevel)
```
```

tl =

2.6861

tu =

3.3848

ifail =

0

```
```function g07ab_example
n = int64(98);
xmean = 3.020408163265306;
clevel = 0.95;
[tl, tu, ifail] = g07ab(n, xmean, clevel)
```
```

tl =

2.6861

tu =

3.3848

ifail =

0

```