|
NAG[g05lzc] NAG[nag_rngs_multi_normal] - Generates a vector of random numbers from a multivariate Normal distribution, seeds and generator number passed explicitly
|
|
Calling Sequence
g05lzc(mode, xmu, c, x, igen, iseed, r, 'n'=n, 'fail'=fail)
nag_rngs_multi_normal(. . .)
Parameters
|
mode - integer;
|
|
|
On entry: selects the operation to be performed:
|
|
Initialize and generate random numbers.
|
|
Initialize only (i.e., set up reference vector).
|
|
Generate random numbers using previously set up reference vector.
|
|
Constraint: . .
|
|
|
xmu - Vector(1..n, datatype=float[8]);
|
|
|
On entry: , the vector of means of the distribution.
|
|
|
c - Matrix(1..dim1, 1..n, datatype=float[8], order=order);
|
|
|
Note: this array may be supplied in Fortran_order or C_order , as specified by order. All array parameters must use a consistent order.
|
|
On entry: the covariance matrix of the distribution. Only the upper triangle need be set.
|
|
Constraint: c must be positive semi-definite to machine precision.
|
|
|
x - Vector(1..n, datatype=float[8]);
|
|
|
On exit: the pseudo-random multivariate Normal vector generated by the function.
|
|
|
iseed - Vector(1.., datatype=integer[kernelopts('wordsize')/8]);
|
|
|
On entry: contains values which define the current state of the selected generator.
|
|
On exit: contains updated values defining the new state of the selected generator.
|
|
|
r - Vector(1.., datatype=float[8]);
|
|
|
Note: the dimension, dim, of the array r must be at least .
|
|
|
'n'=n - integer; (optional)
|
|
|
On entry: , the number of dimensions of the distribution.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_rngs_multi_normal (g05lzc) sets up a reference vector and generates a vector of pseudo-random numbers from a multivariate Normal distribution with mean vector and covariance matrix .
|
|
Description
|
|
When the covariance matrix is non-singular (i.e., strictly positive-definite), the distribution has probability density function
where is the number of dimensions, is the covariance matrix, is the vector of means and is the vector of positions.
Covariance matrices are symmetric and positive semi-definite. Given such a matrix , there exists a lower triangular matrix such that . is not unique, if is singular.
nag_rngs_multi_normal (g05lzc) decomposes to find such an . It then stores , and in the reference vector which is used to generate a vector of independent standard Normal pseudo-random numbers. It then returns the vector , which has the required multivariate Normal distribution.
It should be noted that this function will work with a singular covariance matrix , provided is positive semi-definite, despite the fact that the above formula for the probability density function is not valid in that case. Wilkinson (1965) should be consulted if further information is required.
One of the initialization functions g05kbc (nag_rngs_init_repeatable) (for a repeatable sequence if computed sequentially) or g05kcc (nag_rngs_init_nonrepeatable) (for a non-repeatable sequence) must be called prior to the first call to nag_rngs_multi_normal (g05lzc).
|
|
Error Indicators and Warnings
|
|
"NE_ALLOC_FAIL"
Dynamic memory allocation failed.
"NE_BAD_PARAM"
On entry, argument had an illegal value.
"NE_INT"
On entry, . Constraint: .
On entry, . Constraint: .
"NE_INT_2"
n is not the same as when r was set up in a previous call. Previous value , .
"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 consult NAG for assistance.
"NE_POS_DEF"
The covariance matrix c is not positive semi-definite to machine precision.
|
|
|
Examples
|
|
>
|
mode := 0:
n := 2:
igen := 1:
xmu := Vector([1, 2], datatype=float[8]):
c := Matrix([[2, 1], [1, 3]], datatype=float[8]):
x := Vector(2, datatype=float[8]):
iseed := Vector([1762543, 9324783, 42344, 742355], datatype=integer[kernelopts('wordsize')/8]):
r := Vector([0, 0, 0, 0, 0, 0], datatype=float[8]):
NAG:-g05lzc(mode, xmu, c, x, igen, iseed, r, 'n' = n):
|
|
|