Line 2: Line 2:
  
 
These generate random samples from a multivariate distribution
 
These generate random samples from a multivariate distribution
- You can use mvnrnd(mu,sigma) function in Matlab. (See details below)
+
* You can use mvnrnd(mu,sigma) function in Matlab. (See details below)
- You can use the technique of [Generating Gaussian Samples] (which is good theory to know).
+
* You can use the technique of [Generating Gaussian Samples] (which is good theory to know).
  
 
This calculates the [pdf] function of the multivariate distribution
 
This calculates the [pdf] function of the multivariate distribution
- You can use `multigauss.m <multigauss.m>`_
+
* You can use `multigauss.m <multigauss.m>`_
  
  
Line 18: Line 18:
 
Message-ID: <20080212115456-0500@https://engineering.purdue.edu>
 
Message-ID: <20080212115456-0500@https://engineering.purdue.edu>
  
=> You can use mvnrnd(mu,sigma) function in Matlab.  
+
=> You can use mvnrnd(mu,sigma) function in Matlab.
  
 
::
 
::
  
  MVNRND Random vectors from the multivariate normal distribution.
+
MVNRND Random vectors from the multivariate normal distribution.
    R = MVNRND(MU,SIGMA) returns an N-by-D matrix R of random vectors
+
R = MVNRND(MU,SIGMA) returns an N-by-D matrix R of random vectors
    chosen from the multivariate normal distribution with mean vector MU,
+
chosen from the multivariate normal distribution with mean vector MU,
    and covariance matrix SIGMA.  MU is an N-by-D matrix, and MVNRND
+
and covariance matrix SIGMA.  MU is an N-by-D matrix, and MVNRND
    generates each row of R using the corresponding row of MU.  SIGMA is a
+
generates each row of R using the corresponding row of MU.  SIGMA is a
    D-by-D symmetric positive semi-definite matrix, or a D-by-D-by-N array.
+
D-by-D symmetric positive semi-definite matrix, or a D-by-D-by-N array.
    If SIGMA is an array, MVNRND generates each row of R using the
+
If SIGMA is an array, MVNRND generates each row of R using the
    corresponding page of SIGMA, i.e., MVNRND computes R(I,:) using MU(I,:)
+
corresponding page of SIGMA, i.e., MVNRND computes R(I,:) using MU(I,:)
    and SIGMA(:,:,I).  If MU is a 1-by-D vector, MVNRND replicates it to
+
and SIGMA(:,:,I).  If MU is a 1-by-D vector, MVNRND replicates it to
    match the trailing dimension of SIGMA.
+
match the trailing dimension of SIGMA.
+
    R = MVNRND(MU,SIGMA,N) returns a N-by-D matrix R of random vectors
+
    chosen from the multivariate normal distribution with 1-by-D mean
+
    vector MU, and D-by-D covariance matrix SIGMA.
+
+
    Example:
+
      mu = [1 -1]; Sigma = [.9 .4; .4 .3];
+
      r = mvnrnd(mu, Sigma, 500);
+
      plot(r(:,1),r(:,2),'.');
+
  
+
R = MVNRND(MU,SIGMA,N) returns a N-by-D matrix R of random vectors
    See also mvtrnd, mvnpdf, mvncdf, normrnd.
+
chosen from the multivariate normal distribution with 1-by-D mean
 +
vector MU, and D-by-D covariance matrix SIGMA.
  
 +
Example:
 +
mu = [1 -1]; Sigma = [.9 .4; .4 .3];
 +
r = mvnrnd(mu, Sigma, 500);
 +
plot(r(:,1),r(:,2),'.');
  
    Reference page in Help browser
+
See also mvtrnd, mvnpdf, mvncdf, normrnd.
      doc mvnrnd
+
 
 +
Reference page in Help browser
 +
doc mvnrnd
  
 
Ref: Matlab Help
 
Ref: Matlab Help

Revision as of 17:42, 19 March 2008

There are several ways to create multi-variate data in matlab

These generate random samples from a multivariate distribution

  • You can use mvnrnd(mu,sigma) function in Matlab. (See details below)
  • You can use the technique of [Generating Gaussian Samples] (which is good theory to know).

This calculates the [pdf] function of the multivariate distribution

  • You can use `multigauss.m <multigauss.m>`_


Forum

=

From jin-young.kim.1 Tue Feb 12 11:54:56 -0500 2008 From: jin-young.kim.1 Date: Tue, 12 Feb 2008 11:54:56 -0500 Subject: How to generate multivariate normal distribution using Matlab Message-ID: <20080212115456-0500@https://engineering.purdue.edu>

=> You can use mvnrnd(mu,sigma) function in Matlab.

MVNRND Random vectors from the multivariate normal distribution. R = MVNRND(MU,SIGMA) returns an N-by-D matrix R of random vectors chosen from the multivariate normal distribution with mean vector MU, and covariance matrix SIGMA. MU is an N-by-D matrix, and MVNRND generates each row of R using the corresponding row of MU. SIGMA is a D-by-D symmetric positive semi-definite matrix, or a D-by-D-by-N array. If SIGMA is an array, MVNRND generates each row of R using the corresponding page of SIGMA, i.e., MVNRND computes R(I,:) using MU(I,:) and SIGMA(:,:,I). If MU is a 1-by-D vector, MVNRND replicates it to match the trailing dimension of SIGMA.

R = MVNRND(MU,SIGMA,N) returns a N-by-D matrix R of random vectors chosen from the multivariate normal distribution with 1-by-D mean vector MU, and D-by-D covariance matrix SIGMA.

Example: mu = [1 -1]; Sigma = [.9 .4; .4 .3]; r = mvnrnd(mu, Sigma, 500); plot(r(:,1),r(:,2),'.');

See also mvtrnd, mvnpdf, mvncdf, normrnd.

Reference page in Help browser doc mvnrnd

Ref: Matlab Help

Here is another way to do so (probably what mvnrnd.m is doing in the first place): GeneratingGaussianSamples

From landis.m.huffman.1 Tue Feb 12 23:09:17 -0500 2008 From: landis.m.huffman.1 Date: Tue, 12 Feb 2008 23:09:17 -0500 Subject: Generating Gaussian Samples Message-ID: <20080212230917-0500@https://engineering.purdue.edu>

I worked out a proof for using the Cholsky decomposition of the covariance matrix for [Generating Gaussian Samples]. I suppose you could use this if you were not going to use Matlab, which, as I have found here, already has a canned function for this type of sampling

Alumni Liaison

Ph.D. 2007, working on developing cool imaging technologies for digital cameras, camera phones, and video surveillance cameras.

Buyue Zhang