g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

NAG Library Function Documentnag_ref_vec_poisson (g05ecc)

1  Purpose

nag_ref_vec_poisson (g05ecc) sets up the reference vector r for a Poisson distribution with mean $t$.

2  Specification

 #include #include
 void nag_ref_vec_poisson (double t, double **r, NagError *fail)

3  Description

This sets up a reference vector for use in nag_return_discrete (g05eyc). Together these functions produce random numbers from the Poisson distribution defined by:
 $P I=i = t i e -t i! if ​ i = 0 , 1 , … P I=i = 0 otherwise.$
The reference array is found using a recurrence relation if $t$ is less than 50 and by Stirling's formula otherwise.

4  References

Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin
Knuth D E (1981) The Art of Computer Programming (Volume 2) (2nd Edition) Addison–Wesley

5  Arguments

1:     tdoubleInput
On entry: the mean, $t$, of the distribution.
Constraint: ${\mathbf{t}}\ge 0$.
2:     rdouble **Output
On exit: reference vector for which memory will be allocated internally. If no memory is allocated to r (e.g., when an input error is detected) then r will be NULL on return, otherwise you should use the NAG macro NAG_FREE to free the storage allocated by r when it is no longer of use.
3:     failNagError *Input/Output
The NAG error argument (see Section 3.6 in the Essential Introduction).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_REAL_ARG_LT
On entry, t must not be less than 0.0: ${\mathbf{t}}=〈\mathit{\text{value}}〉$.

Not applicable.

None.

9  Example

The example program sets up a reference for a Poisson distribution with mean 2.7 and then prints the first five pseudorandom numbers generated by nag_return_discrete (g05eyc), after initialization by nag_random_init_repeatable (g05cbc).

9.1  Program Text

Program Text (g05ecce.c)

None.

9.3  Program Results

Program Results (g05ecce.r)