These packages are archived in zip format. All code is available in the public domain under the GPL unless otherwise noted.
This Matlab code generates uniform random vectors while "closely" matching a given correlation matrix. The generation procedure used is the NORTA method (Normal to anything), which is essentially a Gaussian copula. It is known that NORTA cannot exactly match all correlation matrices. This code augments the usual NORTA procedure to deal with this problem. The augmentation ensures that the correlation matrix of the generated vectors is exactly the desired one in many cases, but if that is not possible, then the correlation matrix will be "close" to the desired one. The augmentation can be done in many ways. The code provides a menu of four different heuristics, three of which solve a semi-definite problem (and will need the LMI toolbox installed within Matlab) while the last one is a heuristic that provides a good feasible solution without solving a semi-definite program, and is thus recommended. For full details of why this problem occurs, and the various heuristics for dealing with them, please see Soumyadip Ghosh's thesis. Some aspects of the problem are also discussed in the references below.
This Matlab code illustrates and implements how matrices can be generated uniformly from the space of all n-dimensional matrices that are positive semi-definite and have the a pre-selected set of diagonal values. The simplest case is where all diagonals equal 1, i.e., the set of all n-dimensional matrices that are commonly referred to as correlation matrices. An exact definition of this space and the details of this algorithm can be found in