No BSD License  

Highlights from
MVG Multivariate Gaussian random number generator

5.0

5.0 | 3 ratings Rate this file 14 Downloads (last 30 days) File Size: 1.57 KB File ID: #21279

MVG Multivariate Gaussian random number generator

by Chad Lieberman

 

31 Aug 2008 (Updated 04 Sep 2008)

Generates vectors from the multivariate normal distribution parameterized by specified mean vector a

| Watch this File

File Information
Description

MVG is a multivariate Gaussian (normal) random number generator. A user can generate a vector from the multivariate normal distribution of any dimension by specifying a mean vector and symmetric positive-definite covariance matrix. A linear transformation based on the Cholesky decomposition of the covariance matrix is applied to a set of realizations from the distribution N(0,I). By applying the linear transformation to those samples, the output is a matrix whose columns are samples drawn from the distribution N(mu,Sigma) where mu is the specified mean vector and Sigma is an SPD covariance matrix. Type help mvg to learn more.

MATLAB release MATLAB 7.4 (R2007a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
02 Sep 2008 John D'Errico

Why would you use the central limit theorem to generate approximate normal variates, when randn does so much more accurately, as well as doing so much more quickly? I'm sorry, but that is just a downright ridiculous thing to do.

Looking at the help, it is pretty good. There is a reference, there are readable descriptions of the parameters, etc. I found error checks for the errors one might expect to see.

One issue is the H1 line. There was none. The H1 line is the very FIRST line of comment in the help block. The H1 line is used by lookfor, as well in creating a contents file when necessary.

The funny thing is, the author has written a very serviceable H1 line, but left it as the second comment line, with a blank comment line preceding it. This is silly, since it fails to serve its proper utility.

There are other issues, more grievous ones, I am afraid. The code computes the cholesky factor of the covariance matrix, but for no good reason, since then it next computers the eigenvalue decomposition. Since either of these decompositions will serve to transform a set of independent normal variates into the desired structure, the code does extra work for no valid reason.

Finally, there are at least a few other multivariate normal deviate generation codes on the file exchange. I don't see anything that this improves upon. I've given it as high as a 2 rating only because the help was clearly written.

05 Sep 2008 John D'Errico

Much better now. Problems I noted previously are repaired. I also did not see a truly n-d normal generator after another check, only the 2-d case. So this is more general.

18 Jan 2009 Jøger Hansegård  
Please login to add a comment or rating.
Updates
04 Sep 2008

- used Cholesky decomposition to transform from N(0,I) to N(mu,Sigma)
- constructed appropriate H1 line
- used randn instead of generating approximate normals via rand and central limit theorem

Tag Activity for this File
Tag Applied By Date/Time
statistics Chad Lieberman 22 Oct 2008 10:16:53
probability Chad Lieberman 22 Oct 2008 10:16:53
multivariate Chad Lieberman 22 Oct 2008 10:16:53
gaussian Chad Lieberman 22 Oct 2008 10:16:53
normal Chad Lieberman 22 Oct 2008 10:16:54
generator Chad Lieberman 22 Oct 2008 10:16:54
random Chad Lieberman 22 Oct 2008 10:16:54
normal Voicu 05 Oct 2009 09:28:35
nrz gaussian Mamoon Akhtar 24 May 2010 07:24:40
generator Francesco Pozzi 11 Aug 2011 06:17:31

Contact us at files@mathworks.com