nag_rngs_copula_normal (g05rac) sets up a reference vector and generates an array of pseudorandom numbers from a Normal (Gaussian) copula with covariance matrix .
The Gaussian copula,
, is defined by
where
is the number of dimensions,
is the multivariate Normal density function with mean zero and covariance matrix
and
is the inverse of the univariate Normal density function with mean zero and variance
.
Routine
nag_rgsn_matrix_multi_normal (g05lyc) is used to generate a vector from a multivariate Normal distribution and function
nag_prob_normal (g01eac) is used to convert each element of that vector into a uniformly distributed value between zero and one.
One of the initialization functions
nag_rngs_init_repeatable (g05kbc) (for a repeatable sequence if computed sequentially) or
nag_rngs_init_nonrepeatable (g05kcc) (for a non-repeatable sequence) must be called prior to the first call to nag_rngs_copula_normal (g05rac).
- 1:
order – Nag_OrderTypeInput
-
On entry: the
order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by
. See
Section 3.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint:
or Nag_ColMajor.
- 2:
mode – IntegerInput
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:
, or .
- 3:
m – IntegerInput
On entry:
, the number of dimensions of the distribution.
Constraint:
.
- 4:
c[] – const doubleInput
-
Note: the dimension,
dim, of the array
c
must be at least
.
The
th element of the matrix
is stored in
- when ;
- when .
On entry: the covariance matrix of the distribution. Only the upper triangle need be set.
Constraint:
c must be positive semidefinite to
machine precision.
- 5:
pdc – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
c.
Constraint:
.
- 6:
n – IntegerInput
On entry:
, the number of random variates required.
Constraint:
.
- 7:
x[] – doubleOutput
-
Note: the dimension,
dim, of the array
x
must be at least
- when ;
- when .
The
th element of the
th vector
is stored in
- when ;
- when .
On exit: the array of pseudorandom multivariate Normal vectors.
- 8:
pdx – IntegerInput
-
On entry: the stride used in the array
x.
Constraints:
- if ,
;
- if , .
- 9:
igen – IntegerInput
On entry: must contain the identification number for the generator to be used to return a pseudorandom number and should remain unchanged following initialization by a prior call to
nag_rngs_init_repeatable (g05kbc) or
nag_rngs_init_nonrepeatable (g05kcc).
- 10:
iseed[] – IntegerCommunication Array
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.
- 11:
r[lr] – doubleCommunication Array
On entry: if , the reference vector as set up by nag_rngs_copula_normal (g05rac) in a previous call with or .
On exit: if or , the reference vector that can be used in subsequent calls to nag_rngs_copula_normal (g05rac) with .
- 12:
lr – IntegerInput
On entry: the dimension of the array
r. If
, it must be the same as the value of
lr specified in the prior call to nag_rngs_copula_normal (g05rac) with
or
.
Constraint:
.
- 13:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
- NE_ALLOC_FAIL
Dynamic memory allocation failed.
- NE_BAD_PARAM
On entry, argument had an illegal value.
- NE_INT
On entry, invalid value for
igen. Ensure
igen has not changed since random number generator was initialized.
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: and .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INT_2
m is not the same as when
r was set up in a previous call. Previous value
and
.
On entry, , .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
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.
- NE_POS_DEF
The covariance matrix
c is not positive semidefinite to
machine precision.
See
Section 7 in nag_rgsn_matrix_multi_normal (g05lyc) for an indication of the accuracy of the underlying multivariate Normal distribution.
None.
This example prints ten pseudorandom observations from a Normal copula with covariance matrix
generated by nag_rngs_copula_normal (g05rac). All ten observations are generated by a single call to nag_rngs_copula_normal (g05rac) with
. The random number generator is initialized by
nag_rngs_init_repeatable (g05kbc).
None.