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,] 2.8136991 2.0018524
#> [2,] 0.9433234 1.7617484
#> [3,] 0.7674802 0.3909412
#> [4,] -0.1663155 -0.7883861