header updated
git-svn-id: https://www.dynare.org/svn/dynare/dynare_v4@1631 ac1d8469-bf42-47a9-8791-bf33cf982152time-shift
parent
9152bbbc48
commit
60fdc08e2d
|
@ -1,23 +1,28 @@
|
|||
function B = rand_matrix_normal(n, p, M, Omega_lower_chol, Sigma_lower_chol)
|
||||
% rand_matrix_normal Pseudo random matrices drawn from a
|
||||
% matrix-normal distribution
|
||||
%
|
||||
% B = rand_matrix_normal(n, p, M, Omega_lower_chol, Sigma_lower_chol)
|
||||
%
|
||||
% Returns an n-by-p matrix drawn from a Matrix-normal distribution
|
||||
%
|
||||
% B ~ MN_n*p(M, Omega, Sigma)
|
||||
%
|
||||
|
||||
% function B = rand_matrix_normal(n, p, M, Omega_lower_chol, Sigma_lower_chol)
|
||||
% Pseudo random matrices drawn from a matrix-normal distribution
|
||||
% B ~ MN_n*p(M, Omega, Sigma)
|
||||
% Equivalent to vec(B) ~ N(vec(Mu), kron(Omega, Sigma))
|
||||
%
|
||||
% Same notations than: http://en.wikipedia.org/wiki/Matrix_normal_distribution
|
||||
%
|
||||
% M is the mean, n-by-p matrix
|
||||
% Omega_lower_chol is p-by-p, lower Cholesky decomposition of Omega
|
||||
% (Omega_lower_chol = chol(Omega, 'lower'))
|
||||
% Sigma_lower_chol is n-by-n, lower Cholesky decomposition of Sigma
|
||||
% (Sigma_lower_chol = chol(Sigma, 'lower'))
|
||||
|
||||
% INPUTS
|
||||
% n: row
|
||||
% p: column
|
||||
% M: (n*p) matrix, mean
|
||||
% Omega_lower_chol: (p*p), lower Cholesky decomposition of Omega,
|
||||
% (Omega_lower_chol = chol(Omega, 'lower'))
|
||||
% Sigma_lower_chol: (n*n), lower Cholesky decomposition of Sigma,
|
||||
% (Sigma_lower_chol = chol(Sigma, 'lower'))
|
||||
%
|
||||
% OUTPUTS
|
||||
% B: (n*p) matrix drawn from a Matrix-normal distribution
|
||||
%
|
||||
% SPECIAL REQUIREMENTS
|
||||
% Same notations than: http://en.wikipedia.org/wiki/Matrix_normal_distribution
|
||||
%
|
||||
% part of DYNARE, copyright Dynare Team (2003-2008)
|
||||
% Gnu Public License.
|
||||
|
||||
B1 = randn(n * p, 1);
|
||||
B2 = kron(Omega_lower_chol, Sigma_lower_chol) * B1;
|
||||
B3 = reshape(B2, n, p);
|
||||
|
|
Loading…
Reference in New Issue