Random Multivariate Normal Vectors

Basic Approach

To generate a random vector that comes from a multivariate normal distribution with a 1 × k means vector \bar X and covariance matrix S, generate k random values from a (univariate) standard normal distribution to form a random vector Z. Next, find a k × k matrix A such that ATA = S (e.g. let A be the Cholesky decomposition of S). Then \bar X + AZ is a random vector.

To generate a random vector that comes from a bivariate normal distribution with means m1m2, standard deviations s1, s2, and correlation coefficient r, we simply note that the means vector is \bar X = (m1, m2) and covariance matrix

image291z

Example

Example 1: Generate five random vectors from the multivariate normal distribution defined by the data from Example 1 of Multivariate Normality Functions.

We start by repeating in Figure 1 the data values, mean vector, and covariance matrix from this example.

Bivariate normal distribution example

Figure 1 – Bivariate normal distribution example

We next calculate the Cholesky decomposition of the covariance matrix using the Real Statistics CHOL worksheet function (range I5:J6), and then generate 10 random standard normal distribution values (range I10:M11) as shown in Figure 2.

Random bivariate normal vectors

Figure 1 – Random vectors from bivariate normal distribution

Finally, we generate the five random column vectors shown in ranges I15:I16, J15:J16, K15:K16, L15:L16, and M15:M16.

Worksheet Functions

Real Statistics Functions: The Real Statistics Resource Pack provides the following functions.

MNORMRAND(R1, R2): generates an array containing a random k × 1 vector from a k-dimensional multivariate normal distribution where R1 is the range that contains the k × 1 means vector and R2 is the range that contains the k × k covariance matrix

BNORMRAND(m1, m2, s1, s2, r): generates a random 2 × 1 vector from a bivariate normal distribution with means m1, m2, standard deviations s1, s2 and correlation coefficient r.

We can use the BNORMRAND function to generate the five random vectors for Example 1, as shown in ranges I20:I21, J20:J21, K20:K21, L20:L21, and M20:M21 of Figure 2.

Motivation

As we see in Other Multivariate Normal Properties, if Z is the standardization of vector X, then Z = (AT)-1(X–μ) where Σ = ATA. If you have a value for Z, then X can be expressed as X = μ + ATZ. Substituting \bar X for μ and S for Σ yields the expression X = \bar X + AZ shown previously.

The advantage of this expression is that a random value for Z can be found very easily. Since ZN(0, I), all the covariances are zero, and so we just need to create k univariate standard normal values to obtain the k × 1 vector Z. This yields a random value for X = \bar X + AZ.

Examples Workbook

Click here to download the Excel workbook with the examples described on this webpage.

References

Rencher, A.C. (2002) Methods of multivariate analysis (2nd Ed). Wiley-Interscience, New York.

Azevedo, C. L. N. (2016) The Multivariate Normal Distribution
https://www.ime.unicamp.br/~cnaber/mvnprop.pdf

8 thoughts on “Random Multivariate Normal Vectors”

  1. Hello Prof. Thanks for your effort.
    Pls i am finding it difficult to compute the rS1S2 in the variance covariance matrix of S above, i dont really know or to get the r; I hope you can assist me.
    Thanks very much

    Reply
  2. dear professor,
    How to run MVN.
    The above exmaple does not display running steps.
    It shows the formula only.
    Should we run step by step?

    Reply
    • Yes, you should use a step by step approach. Start as follows:
      1. Calculate covariance matrix (D5:E6)
      2. Calculate the means (E10 and E11)
      3. Calculate Cholesky (I5:J6)
      Now, for each random vector that you want to generate
      4. Calculate random values from the univariate normal distributions (I10:I11)
      5. Calculate a random bivariate normal vector (I15:I16)
      You can also generate random vectors by using the Real Statistics array formula in range I19:I20.
      Charles

      Reply
  3. HI, I am teaching Simulation in my class. For Mac using students, I let them use MNORMRAND function for correlated random number generation.

    One of my students asked me to help with MNORMRAND. I get his file and I checked, it works fine on my Mac (generating three correlated random numbers). But on his computer, it generates only one random number.
    It seems some kind of setting in Excel makes the difference.

    Do you have any idea what would make this difference?

    Thanks.

    Reply
  4. Sorry, I’m getting “#value!” errors in a simple 4-variable test use of MNORMRAND(). I have negative covariances throughout (off-diagonal elements), but it also fails if I make those positive.

    Any sense of what I’m doing wrong?

    Var-Covar Matrix 50%
    Coeff Estimate StdDev Variance A-PDE A-Sample A-Dinner A-Digital
    A-PDE 12 3.1 9.61 A-PDE 9.61 -2.8925 -2.465 -2.6525
    A-Sample 3 1.4 1.96 A-Sample -2.8925 1.96 -0.5525 -0.74
    A-Dinner 1.7 0.5 0.25 A-Dinner -2.465 -0.5525 0.25 -0.3125
    A-Digital 2 1 1 A-Digital -2.6525 -0.74 -0.3125 1

    Random Vectors
    A-PDE #VALUE!
    A-Sample #VALUE!
    A-Dinner #VALUE!
    A-Digital #VALUE!

    Reply

Leave a Comment