Given
$n$ eigenvalues,
${\lambda}_{1},{\lambda}_{2},\dots ,{\lambda}_{n}$, such that
and
g05pyf will generate a random correlation matrix,
$C$, of dimension
$n$, with eigenvalues
${\lambda}_{1},{\lambda}_{2},\dots ,{\lambda}_{n}$.
The method used is based on that described by
Lin and Bendel (1985). Let
$D$ be the diagonal matrix with values
${\lambda}_{1},{\lambda}_{2},\dots ,{\lambda}_{n}$ and let
$A$ be a random orthogonal matrix generated by
g05pxf then the matrix
${C}_{0}=AD{A}^{\mathrm{T}}$ is a random covariance matrix with eigenvalues
${\lambda}_{1},{\lambda}_{2},\dots ,{\lambda}_{n}$. The matrix
${C}_{0}$ is transformed into a correlation matrix by means of
$n1$ elementary rotation matrices
${P}_{i}$ such that
$C={P}_{n1}{P}_{n2}\dots {P}_{1}{C}_{0}{P}_{1}^{\mathrm{T}}\dots {P}_{n2}^{\mathrm{T}}{P}_{n1}^{\mathrm{T}}$. The restriction on the sum of eigenvalues implies that for any diagonal element of
${C}_{0}>1$, there is another diagonal element
$\text{}<1$. The
${P}_{i}$ are constructed from such pairs, chosen at random, to produce a unit diagonal element corresponding to the first element. This is repeated until all diagonal elements are
$1$ to within a given tolerance
$\epsilon $.
One of the initialization routines
g05kff (for a repeatable sequence if computed sequentially) or
g05kgf (for a nonrepeatable sequence) must be called prior to the first call to
g05pyf.
Lin S P and Bendel R B (1985) Algorithm AS 213: Generation of population correlation on matrices with specified eigenvalues Appl. Statist. 34 193–198
 1: $\mathbf{n}$ – IntegerInput

On entry: $n$, the dimension of the correlation matrix to be generated.
Constraint:
${\mathbf{n}}\ge 1$.
 2: $\mathbf{d}\left({\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayInput

On entry: the $n$ eigenvalues,
${\lambda}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.
Constraints:
 ${\mathbf{d}}\left(\mathit{i}\right)\ge 0.0$, for $\mathit{i}=1,2,\dots ,n$;
 $\sum _{i=1}^{n}}{\mathbf{d}}\left(i\right)=n$ to within eps.
 3: $\mathbf{eps}$ – Real (Kind=nag_wp)Input

On entry: the maximum acceptable error in the diagonal elements.
Suggested value:
${\mathbf{eps}}=0.00001$.
Constraint:
${\mathbf{eps}}\ge {\mathbf{n}}\times \mathit{machineprecision}$ (see
Chapter X02).
 4: $\mathbf{state}\left(*\right)$ – Integer arrayCommunication Array

Note: the actual argument supplied
must be the array
state supplied to the initialization routines
g05kff or
g05kgf.
On entry: contains information on the selected base generator and its current state.
On exit: contains updated information on the state of the generator.
 5: $\mathbf{c}\left({\mathbf{ldc}},{\mathbf{n}}\right)$ – Real (Kind=nag_wp) arrayOutput

On exit: a random correlation matrix, $C$, of dimension $n$.
 6: $\mathbf{ldc}$ – IntegerInput

On entry: the first dimension of the array
c as declared in the (sub)program from which
g05pyf is called.
Constraint:
${\mathbf{ldc}}\ge {\mathbf{n}}$.
 7: $\mathbf{ifail}$ – IntegerInput/Output

On entry:
ifail must be set to
$0$,
$1\text{ or}1$. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
$1\text{ or}1$ is recommended. If the output of error messages is undesirable, then the value
$1$ is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
$0$.
When the value $\mathbf{1}\text{ or}\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit:
${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
If on entry
${\mathbf{ifail}}=0$ or
$1$, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
The maximum error in a diagonal element is given by
eps.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.
Following initialization of the pseudorandom number generator by a call to
g05kff, a
$3$ by
$3$ correlation matrix with eigenvalues of
$0.7$,
$0.9$ and
$1.4$ is generated and printed.