Generates multivariate Normal pseudo-random numbers (P.W. Goedhart & K.L. Moore).

### Options

`NVALUES` = scalar |
Number of values to generate; default 1 |
---|---|

`MEANS` = variate |
The mean for the multivariate Normal distribution; default is a variate with values all equal to 0 |

`VCOVARIANCE` = symmetric matrix |
The variance/covariance matrix for the multivariate Normal distribution; default is to use an identity matrix |

`SEED` = scalar |
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 |

### Parameters

`NUMBERS` = pointers or matrices |
Saves the random numbers as either a pointer to a set of variates or a matrix |
---|

### Description

`GRMULTINORMAL`

generates pseudo-random numbers from a multivariate Normal distribution N_{p}(μ, Σ). The mean μ is specified by the option `MEANS`

as a variate of length *p*; the variance-covariance matrix Σ is specified by the option `VCOVARIANCE`

as `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 `NVALUES`

, `MEANS`

and `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.

Options: `NVALUES`

, `MEANS`

, `VCOVARIANCE`

.

Parameter: `NUMBERS`

.

### Method

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).

### Action with `RESTRICT`

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.

### References

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.

### See also

Directive: `CALCULATE`

.

Procedures: `GRCSR`

, `GREJECTIONSAMPLE`

, `GRLABEL`

, `GRTHIN`

, `GRTORSHIFT`

, `SAMPLE`

, `SVSAMPLE`

.

Functions: `GRBETA`

, `GRBINOMIAL`

, `GRCHISQUARE`

, `GRF`

, `GRGAMMA`

, `GRHYPERGEOMETRIC`

, `GRLOGNORMAL`

, `GRNORMAL`

, `GRPOISSON`

, `GRSAMPLE`

, `GRSELECT`

, `GRT`

, `GRUNIFORM`

.

Commands for: Calculations and manipulation.

### Example

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