|
NAG[g05eac] NAG[nag_ref_vec_multi_normal] - Set up reference vector for multivariate Normal distribution
|
|
Calling Sequence
g05eac(a, c, eps, r, 'n'=n, 'tdc'=tdc, 'fail'=fail)
nag_ref_vec_multi_normal(. . .)
Parameters
|
a - Vector(1..n, datatype=float[8]);
|
|
|
On entry: the vector of means, , of the distribution.
|
|
|
c - Matrix(1..n, 1..tdc, datatype=float[8], order=C_order);
|
|
|
On entry: the variance-covariance matrix of the distribution. Only the upper triangle need be set.
|
|
|
eps - float;
|
|
|
On entry: the maximum error in any element of , relative to the largest element of .
|
|
Constraint: . .
|
|
|
r - assignable;
|
|
|
Note: On exit the variable r will have a value of type REF(float).
|
|
On exit: reference vector for which memory will be allocated internally. This reference vector will subsequently be used by g05ezc (nag_return_multi_normal). If no memory is allocated to r (e.g., when an input error is detected) then r will be NULL on return, otherwise the user should use the NAG macro NAG_FREE to free the storage allocated by r when it is no longer of use.
|
|
|
'n'=n - integer; (optional)
|
|
|
Default value: the first dimension of the arrays a, c and the second dimension of the arrays a, cthe array c.
|
|
On entry: the number of dimensions, , of the distribution.
|
|
Constraint: . .
|
|
|
'tdc'=tdc - integer; (optional)
|
|
|
On entry: the second dimension of the array c as declared in the function from which nag_ref_vec_multi_normal (g05eac) is called.
|
|
Constraint: . .
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_ref_vec_multi_normal (g05eac) sets up a reference vector for a multivariate Normal distribution with mean vector and variance-covariance matrix , so that g05ezc (nag_return_multi_normal) may be used to generate pseudo-random vectors.
|
|
Description
|
|
When the variance-covariance matrix is non-singular (i.e., strictly positive-definite), the distribution has probability density function
where is the number of dimensions, is the variance-covariance matrix, is the vector of means and is the vector of positions.
Variance-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_ref_vec_multi_normal (g05eac) decomposes to find such an . It then stores , and in the reference vector for later use by g05ezc (nag_return_multi_normal). g05ezc (nag_return_multi_normal) generates 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 variance-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.
|
|
Error Indicators and Warnings
|
|
"NE_2_REAL_ARG_GT"
On entry, while 0.1/. These arguments must satisfy /n.
"NE_ALLOC_FAIL"
Dynamic memory allocation failed.
"NE_INT_ARG_LT"
On entry, n must not be less than 1: .
"NE_NOT_POS_SEM_DEF"
Matrix is not positive semi-definite.
"NE_REAL_ARG_LT"
On entry, eps must not be less than 0.0: .
|
|
|
Examples
|
|
>
|
n := 2:
tdc := 2:
eps := 0.01:
a := Vector([1, 2], datatype=float[8]):
c := Matrix([[2, 1], [1, 3]], datatype=float[8], order='C_order'):
NAG:-g05cbc(0):
NAG:-g05eac(a, c, eps, r, 'n' = n, 'tdc' = tdc):
z := Vector[row](n,datatype=float[8]):
ans := Matrix(5,2,[[1.7697,4.4481],[3.2678, 3.0583],[3.1769, 2.3651],
[-0.1055, 1.8395],[1.2933, -0.1850]],datatype=float[8]):
for i from 1 to 5 do
NAG:-g05ezc(z,r):
end do:
|
|
|