PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_rand_copula_students_t (g05rc)
Purpose
nag_rand_copula_students_t (g05rc) sets up a reference vector and generates an array of pseudorandom numbers from a Student's copula with degrees of freedom and covariance matrix .
Syntax
[
r,
state,
x,
ifail] = g05rc(
mode,
n,
df,
c,
r,
state, 'm',
m, 'lr',
lr)
[
r,
state,
x,
ifail] = nag_rand_copula_students_t(
mode,
n,
df,
c,
r,
state, 'm',
m, 'lr',
lr)
Description
The Student's
copula,
, is defined by
where
is the number of dimensions,
is the multivariate Student's
density function with
degrees of freedom, mean zero and covariance matrix
and
is the inverse of the univariate Student's
density function with
degrees of freedom, zero mean and variance
.
nag_rand_multivar_students_t (g05ry) is used to generate a vector from a multivariate Student's
distribution and
nag_stat_prob_students_t (g01eb) is used to convert each element of that vector into a uniformly distributed value between zero and one.
One of the initialization functions
nag_rand_init_repeat (g05kf) (for a repeatable sequence if computed sequentially) or
nag_rand_init_nonrepeat (g05kg) (for a non-repeatable sequence) must be called prior to the first call to
nag_rand_copula_students_t (g05rc).
References
Nelsen R B (1998) An Introduction to Copulas. Lecture Notes in Statistics 139 Springer
Sklar A (1973) Random variables: joint distribution functions and copulas Kybernetika 9 499–460
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
A code for selecting the operation to be performed by the function.
- Set up reference vector only.
- Generate variates using reference vector set up in a prior call to nag_rand_copula_students_t (g05rc).
- Set up reference vector and generate variates.
Constraint:
, or .
- 2:
– int64int32nag_int scalar
-
, the number of random variates required.
Constraint:
.
- 3:
– int64int32nag_int scalar
-
, the number of degrees of freedom of the distribution.
Constraint:
.
- 4:
– double array
-
ldc, the first dimension of the array, must satisfy the constraint
.
Matrix which, along with
df, defines the covariance of the distribution. Only the upper triangle need be set.
Constraint:
must be positive semidefinite to
machine precision.
- 5:
– double array
-
If , the reference vector as set up by nag_rand_copula_students_t (g05rc) in a previous call with or .
- 6:
– int64int32nag_int array
-
Note: the actual argument supplied
must be the array
state supplied to the initialization routines
nag_rand_init_repeat (g05kf) or
nag_rand_init_nonrepeat (g05kg).
Contains information on the selected base generator and its current state.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
c and the second dimension of the array
c. (An error is raised if these dimensions are not equal.)
, the number of dimensions of the distribution.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the array
r.
The dimension of the array
r. if
, it must be the same as the value of
lr specified in the prior call to
nag_rand_copula_students_t (g05rc) with
or
.
Constraint:
.
Output Parameters
- 1:
– double array
-
If or , the reference vector that can be used in subsequent calls to nag_rand_copula_students_t (g05rc) with .
- 2:
– int64int32nag_int array
-
Contains updated information on the state of the generator.
- 3:
– double array
-
The array of values from a multivariate Student's copula, with holding the th dimension for the th variate.
- 4:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
Constraint: , or .
-
-
Constraint: .
-
-
Constraint: .
-
-
Constraint: .
-
-
On entry, the covariance matrix
is not positive semidefinite to
machine precision.
-
-
Constraint: .
-
-
m is not the same as when
r was set up in a previous call.
-
-
On entry,
lr is not large enough,
: minimum length required .
-
-
On entry,
state vector has been corrupted or not initialized.
-
-
Constraint: .
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
See
Accuracy in
nag_rand_multivar_students_t (g05ry) for an indication of the accuracy of the underlying multivariate Student's
-distribution.
Further Comments
The time taken by nag_rand_copula_students_t (g05rc) is of order .
It is recommended that the diagonal elements of
should not differ too widely in order of magnitude. This may be achieved by scaling the variables if necessary. The actual matrix decomposed is
, where
is a diagonal matrix with small positive diagonal elements. This ensures that, even when
is singular, or nearly singular, the Cholesky factor
corresponds to a positive definite covariance matrix that agrees with
within
machine precision.
Example
This example prints ten pseudorandom observations from a Student's
copula with ten degrees of freedom and
matrix
generated by
nag_rand_copula_students_t (g05rc). All ten observations are generated by a single call to
nag_rand_copula_students_t (g05rc) with
. The random number generator is initialized by
nag_rand_init_repeat (g05kf).
Open in the MATLAB editor:
g05rc_example
function g05rc_example
fprintf('g05rc example results\n\n');
seed = [int64(1762543)];
genid = int64(1);
subid = int64(1);
[state, ifail] = g05kf( ...
genid, subid, seed);
n = int64(10);
df = int64(10);
c = [ 1.69, 0.39, -1.86, 0.07;
0, 98.01, -7.07, -0.71;
0, 0, 11.56, 0.03;
0, 0, 0, 0.01];
m = size(c,1);
mode = int64(2);
lr = m*(m+1) + 2;
r = zeros(lr, 1);
[r, state, x, ifail] = g05rc( ...
mode, n, df, c, r, state);
disp('Variates');
disp(x);
g05rc example results
Variates
0.6445 0.0527 0.4082 0.8876
0.0701 0.1988 0.8471 0.3521
0.7988 0.6664 0.2194 0.5541
0.8202 0.0492 0.7059 0.9341
0.1786 0.5594 0.7810 0.2836
0.4920 0.2677 0.3427 0.5169
0.4139 0.2978 0.8762 0.7145
0.7437 0.9714 0.8931 0.2487
0.4971 0.9687 0.8142 0.1965
0.6464 0.5304 0.5817 0.4565
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015