NAG C Library Function Document
nag_poisson_ci (g07abc)
1
Purpose
nag_poisson_ci (g07abc) computes a confidence interval for the mean parameter of the Poisson distribution.
2
Specification
#include <nag.h> |
#include <nagg07.h> |
void |
nag_poisson_ci (Integer n,
double xmean,
double clevel,
double *tl,
double *tu,
NagError *fail) |
|
3
Description
Given a random sample of size
, denoted by
, from a Poisson distribution with probability function
the point estimate,
, for
is the sample mean,
.
Given and this function computes a confidence interval for the parameter , denoted by [], where is in the interval .
The lower and upper confidence limits are estimated by the solutions to the equations
where
.
The relationship between the Poisson distribution and the
-distribution (see page 112 of
Hastings and Peacock (1975)) is used to derive the equations
where
is the deviate associated with the lower tail probability
of the
-distribution with
degrees of freedom.
In turn the relationship between the
-distribution and the gamma distribution (see page 70 of
Hastings and Peacock (1975)) yields the following equivalent equations;
where
is the deviate associated with the lower tail probability,
, of the gamma distribution with shape parameter
and scale parameter
. These deviates are computed using
nag_deviates_gamma_dist (g01ffc).
4
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
5
Arguments
- 1:
– IntegerInput
-
On entry: , the sample size.
Constraint:
.
- 2:
– doubleInput
-
On entry: the sample mean, .
Constraint:
.
- 3:
– doubleInput
-
On entry: the confidence level, , for two-sided interval estimate. For example gives a confidence interval.
Constraint:
.
- 4:
– double *Output
-
On exit: the lower limit, , of the confidence interval.
- 5:
– double *Output
-
On exit: the upper limit, , of the confidence interval.
- 6:
– NagError *Input/Output
-
The NAG error argument (see
Section 3.7 in How to Use the NAG Library and its Documentation).
6
Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
See
Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_CONVERGENCE
-
When using the relationship with the gamma distribution the series to calculate the gamma probabilities has failed to converge. Both
tl and
tu are set to zero. This is an unlikely error exit.
- NE_INT
-
On entry, .
Constraint: .
- 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.
See
Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
- NE_NO_LICENCE
-
Your licence key may have expired or may not have been installed correctly.
See
Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
- NE_REAL
-
On entry, .
Constraint: .
On entry, .
Constraint: .
7
Accuracy
For most cases the results should have a relative accuracy of
where
is the
machine precision (see
nag_machine_precision (X02AJC)). Thus on machines with sufficiently high precision the results should be accurate to
significant digits. Some accuracy may be lost when
or
is very close to
, which will occur if
clevel is very close to
. This should not affect the usual confidence intervals used.
8
Parallelism and Performance
nag_poisson_ci (g07abc) is not threaded in any implementation.
None.
10
Example
The following example reads in data showing the number of noxious weed seeds and the frequency with which that number occurred in
subsamples of meadow grass. The data is taken from page 224 of
Snedecor and Cochran (1967). The sample mean is computed as the point estimate of the Poisson parameter
.
nag_poisson_ci (g07abc) is then called to compute both a 95% and a 99% confidence interval for the parameter
.
10.1
Program Text
Program Text (g07abce.c)
10.2
Program Data
Program Data (g07abce.d)
10.3
Program Results
Program Results (g07abce.r)