Sample from a matrix-normal distribution
Value
A single sample from a matrix-normal distribution with mean
mu (a matrix), row-wise covariances sigma_rows, and column-wise
covariances sigma_cols, where L_sigma_rows and L_sigma_cols are the
Cholesky-decomposed covariance matrices
Examples
mu <- matrix(rep(0, 8), nrow = 4)
sd_rows <- rep(1, 4)
sd_cols <- rep(1, 2)
r_rows <- cor_matrix(.25, 4)
r_cols <- cor_matrix(.75, 2)
L_sigma_rows <- chol(cov_matrix(sd_rows, r_rows))
L_sigma_cols <- chol(cov_matrix(sd_cols, r_cols))
rmatrixnorm(mu, L_sigma_rows, L_sigma_cols)
#> [,1] [,2]
#> [1,] 0.3508829 0.7375118
#> [2,] -0.6929712 -0.6020810
#> [3,] -0.8014975 0.8334889
#> [4,] -0.1011684 0.8001150