Learn R Programming

robustmatrix (version 0.1.3)

rmatnorm: Simulate from a Matrix Normal Distribution

Description

Simulate from a Matrix Normal Distribution

Usage

rmatnorm(n, mu = NULL, cov_row, cov_col)

Value

If \(n = 1\) a matrix with \(p\) rows and \(q\) columns, o otherwise a 3d array of dimensions \((p,q,n)\) with a sample in each slice.

Arguments

n

the number of samples required.

mu

a \(p \times q\) matrix containing the means.

cov_row

a \(p \times p\) positive-definite symmetric matrix specifying the rowwise covariance matrix

cov_col

a \(q \times q\) positive-definite symmetric matrix specifying the columnwise covariance matrix

Examples

Run this code
n = 1000; p = 2; q = 3
mu = matrix(rep(0, p*q), nrow = p, ncol = q)
cov_row = matrix(c(5,2,2,4), nrow = p, ncol = p)
cov_col = matrix(c(3,2,1,2,3,2,1,2,3), nrow = q, ncol = q)
X <- rmatnorm(n = 1000, mu, cov_row, cov_col)
X[,,9] #printing the 9th sample.

Run the code above in your browser using DataLab