RAND_ORTH_MAT Function
Generates a pseudorandom orthogonal matrix or a correlation matrix.
Usage
result = RAND_ORTH_MAT(n)
Input Parameters
nThe order of the matrix to be generated.
Returned Value
result—A two-dimensional array containing the n by n random correlation matrix.
Input Keywords
Double—If present and nonzero, double precision is used.
Eigenvalues—One-dimensional array of length n containing the eigenvalues of the correlation matrix to be generated. The elements of Eigenvalues must be positive, they must sum to n, and they cannot all be equal.
A_Matrix—Two-dimensional array containing n by n random orthogonal matrix. A random correlation matrix is generated using orthogonal matrix input in A_Matrix. Eigenvalues must also be supplied if A_Matrix is used.
Discussion
RAND_ORTH_MAT generates a pseudorandom orthogonal matrix from the invariant Haar measure. For each column, a random vector from a uniform distribution on a hypersphere is selected and then is projected onto the orthogonal complement of the columns already formed. The method is described by Heiberger (1978). (See also Tanner and Thisted 1982.)
If Eigenvalues is used, a correlation matrix is formed by applying a sequence of planar rotations to matrix ATDA, where D = diag(Eigenvalues(0), ..., Eigenvalues(n-1)), so as to yield ones along the diagonal. The planar rotations are applied in such an order that in the two by two matrix that determines the rotation, one diagonal element is less than 1.0 and one is greater than 1.0. This method is discussed by Bendel and Mickey (1978) and by Lin and Bendel (1985).
The distribution of the correlation matrices produced by this method is not known. See Bendel and Mickey (1978) and Johnson and Welch (1980).
For larger matrices, rounding can become severe; and the double precision results may differ significantly from single precision results.
Example
In this example, RAND_ORTH_MAT is used to generate a 4 by 4 pseudorandom correlation matrix with eigenvalues in the ratio 1:2:3:4.
RANDOMOPT, set = 123457
a = RAND_ORTH_MAT(4)
ev = .4d0*[1.0d0, 2.0d0, 3.0d0, 4.0d0]
cor = RAND_ORTH_MAT(n, Eigenvalues = ev, A_Matrix= a)
PM, cor
; PV-WAVE prints the following:
;  1.00000   -0.235786   -0.325795   -0.110139
; -0.235786   1.00000     0.190564   -0.0172391
; -0.325795   0.190564    1.00000    -0.435339
; -0.110139  -0.0172391  -0.435339    1.00000