g05tk generates a vector of pseudorandom integers, each from a discrete Poisson distribution with differing parameter.

Syntax

C#
public static void g05tk(
	int m,
	double[] vlamda,
	G05..::..G05State g05state,
	int[] x,
	out int ifail
)
Visual Basic
Public Shared Sub g05tk ( _
	m As Integer, _
	vlamda As Double(), _
	g05state As G05..::..G05State, _
	x As Integer(), _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g05tk(
	int m, 
	array<double>^ vlamda, 
	G05..::..G05State^ g05state, 
	array<int>^ x, 
	[OutAttribute] int% ifail
)
F#
static member g05tk : 
        m : int * 
        vlamda : float[] * 
        g05state : G05..::..G05State * 
        x : int[] * 
        ifail : int byref -> unit 

Parameters

m
Type: System..::..Int32
On entry: m, the number of Poisson distributions for which pseudorandom variates are required.
Constraint: m1.
vlamda
Type: array<System..::..Double>[]()[][]
An array of size [m]
On entry: the means, λj, for j=1,2,,m, of the Poisson distributions.
Constraint: 0.0vlamda[j-1]x02bb/2.0, for j=1,2,,m.
g05state
Type: NagLibrary..::..G05..::..G05State
An Object of type G05.G05State.
x
Type: array<System..::..Int32>[]()[][]
An array of size [m]
On exit: the m pseudorandom numbers from the specified Poisson distributions.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

Description

g05tk generates m integers xj, each from a discrete Poisson distribution with mean λj, where the probability of xj=I is
Pxj=I=λjI×e-λjI!,  I=0,1,,
where
λj0,  j=1,2,,m.
The methods used by this method have low set up times and are designed for efficient use when the value of the parameter λ changes during the simulation. For large samples from a distribution with fixed λ using g05tj to set up and use a reference vector may be more efficient.
When λ<7.5 the product of uniforms method is used, see for example Dagpunar (1988). For larger values of λ an envelope rejection method is used with a target distribution:
fx=13if ​x1,fx=13x-3otherwise.
This distribution is generated using a ratio of uniforms method. A similar approach has also been suggested by Ahrens and Dieter (1989). The basic method is combined with quick acceptance and rejection tests given by Maclaren (1990). For values of λ87 Stirling's approximation is used in the computation of the Poisson distribution function, otherwise tables of factorials are used as suggested by Maclaren (1990).
One of the initialization methods (G05KFF not in this release) (for a repeatable sequence if computed sequentially) or (G05KGF not in this release) (for a non-repeatable sequence) must be called prior to the first call to g05tk.

References

Ahrens J H and Dieter U (1989) A convenient sampling method with bounded computation times for Poisson distributions Amer. J. Math. Management Sci. 1–13
Dagpunar J (1988) Principles of Random Variate Generation Oxford University Press
Maclaren N M (1990) A Poisson random number generator Personal Communication

Error Indicators and Warnings

Errors or warnings detected by the method:
ifail=1
On entry, m<1.
ifail=2
On entry, vlamda[j-1]<0.0 for at least one value of j.
On entry, 2×vlamda[j-1]>x02bb for at least one value of j.
ifail=3
On entry,state vector was not initialized or has been corrupted.
ifail=-9000
An error occured, see message report.
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

Not applicable.

Parallelism and Performance

None.

Further Comments

None.

Example

See Also