Generates multivariate Normal pseudo-random numbers (P.W. Goedhart & K.L. Moore).
||Number of values to generate; default 1|
||The mean for the multivariate Normal distribution; default is a variate with values all equal to 0|
||The variance/covariance matrix for the multivariate Normal distribution; default is to use an identity matrix|
||Seed to generate the random numbers; default 0 continues an existing sequence or initializes the sequence automatically if no random numbers have been generated in this job|
||Saves the random numbers as either a pointer to a set of variates or a matrix|
GRMULTINORMAL generates pseudo-random numbers from a multivariate Normal distribution Np(μ, Σ). The mean μ is specified by the option
MEANS as a variate of length p; the variance-covariance matrix Σ is specified by the option
a symmetric matrix with p rows and columns; and the option
NVALUES specifies the number of values n to be generated. Note that
VCOVARIANCE must be positive semi-definite.
The numbers can be saved using the
NUMBERS parameter, in either a pointer to a set of variates, or a matrix. If the
NUMBERS structure or structures are already declared, their dimensions must be compatible with the settings of the
VCOVARIANCE options. The dimensions are also used, if necessary, to set defaults for the options. By default,
MEANS is taken to be a variate of zero values, and
VCOVARIANCE is taken to be the identity matrix. If the setting of
NUMBERS is not already declared, if will be defined as a pointer to a set of variates with dimensions deduced from the option settings.
Pseudo-random numbers from a multivariate Normal distribution are generated by forming a matrix Y of columns of univariate Normal random numbers, using the Box-Muller method (Box & Muller 1958), followed by a linear transformation
X = A Y + μ,
where A is calculated by a
CHOLESKI decomposition, AA′ = Σ. (See, for example, Johnson 1987 pages 52-55, Tong 1990 pages 181-186).
Variates that have been restricted will receive output from
GRMULTINORMAL only in those units that are not excluded by the restriction. Values in the excluded units remain unchanged. Note that the
NVALUES option must equal the full size of the variates. Restrictions on the
MEANS variate are ignored.
Box, G.E.P. & Muller, M.E. (1958). A note on generation of normal deviates. Annals of Mathematical Statistics, 28, 610-611.
Johnson, M.E. (1987). Multivariate Statistical Simulation. John Wiley & Sons, New York.
Tong, Y.L. (1990). The Multivariate Normal Distribution. Springer-Verlag, New York.
Commands for: Calculations and manipulation.
CAPTION 'GRMULTINORMAL example'; STYLE=meta MATRIX [ROWS=1000; COLUMN=5] random VARIATE [NVALUES=5; VALUE=(1...5)] mu SYMMETRICMATRIX [ROWS=5; VALUE=10,4,10,3,4,10,2,3,4,10,1,2,3,4,10] sigma,vcov GRMULTINORMAL [NVALUES=1000; MEANS=mu; VCOVARIANCE=sigma; SEED=57653] random CALC vcov$[1...5] = VAR(random$[*;1...5]) & vcov$[1;2...5] = COV(random$[*;1]; random$[*;2...5]) & vcov$[2;3...5] = COV(random$[*;2]; random$[*;3...5]) & vcov$[3;4...5] = COV(random$[*;3]; random$[*;4...5]) & vcov$[4;5] = COV(random$[*;4]; random$[*;5]) PRINT sigma,vcov; DECIMALS=2