Home > matlab > distributions > rand_multivariate_normal.m

rand_multivariate_normal

PURPOSE ^

Pseudo random draws from a multivariate normal distribution,

SYNOPSIS ^

function draw = rand_multivariate_normal(Mean,Sigma_upper_chol,n)

DESCRIPTION ^

 Pseudo random draws from a multivariate normal distribution,
 \mathcal N_n(Mean,Sigma), with expectation Mean and variance Sigma.

 INPUTS 

    Mean               [double]    1*n vector, expectation of the multivariate random variable.
    Sigma_upper_chol   [double]    n*n matrix, upper triangular Cholesky decomposition of Sigma (the covariance matrix).
    n                  [integer]   dimension.
    
 OUTPUTS 
    draw               [double]    1*n vector drawn from a multivariate normal distribution with expectation Mean and
                                   covariance Sigma 
        
 SPECIAL REQUIREMENTS

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function draw = rand_multivariate_normal(Mean,Sigma_upper_chol,n)
0002 % Pseudo random draws from a multivariate normal distribution,
0003 % \mathcal N_n(Mean,Sigma), with expectation Mean and variance Sigma.
0004 %
0005 % INPUTS
0006 %
0007 %    Mean               [double]    1*n vector, expectation of the multivariate random variable.
0008 %    Sigma_upper_chol   [double]    n*n matrix, upper triangular Cholesky decomposition of Sigma (the covariance matrix).
0009 %    n                  [integer]   dimension.
0010 %
0011 % OUTPUTS
0012 %    draw               [double]    1*n vector drawn from a multivariate normal distribution with expectation Mean and
0013 %                                   covariance Sigma
0014 %
0015 % SPECIAL REQUIREMENTS
0016 
0017 % Copyright (C) 2003-2009 Dynare Team
0018 %
0019 % This file is part of Dynare.
0020 %
0021 % Dynare is free software: you can redistribute it and/or modify
0022 % it under the terms of the GNU General Public License as published by
0023 % the Free Software Foundation, either version 3 of the License, or
0024 % (at your option) any later version.
0025 %
0026 % Dynare is distributed in the hope that it will be useful,
0027 % but WITHOUT ANY WARRANTY; without even the implied warranty of
0028 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0029 % GNU General Public License for more details.
0030 %
0031 % You should have received a copy of the GNU General Public License
0032 % along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
0033 
0034 draw = Mean + randn(1,n) * Sigma_upper_chol;

Generated on Mon 21-May-2012 02:42:43 by m2html © 2005