Skip to contents

This function samples a covariance matrix from an inverse Wishart distribution.

Usage

sample_covariance_matrix(dim, df = dim, scale = diag(dim), diag = FALSE)

Arguments

dim

[integer(1)]
The dimension.

df

[numeric(1)]
The degrees of freedom of the inverse Wishart distribution greater or equal dim.

scale

[matrix()]
The positive definite scale covariance matrix of the inverse Wishart distribution of dimension dim.

diag

[logical(1)]
Return a diagonal matrix (by setting the covariances to zero)?

Value

A covariance matrix.

Examples

sample_covariance_matrix(dim = 3)
#>            [,1]      [,2]      [,3]
#> [1,]   277.8455 -1547.210 -357.8158
#> [2,] -1547.2101  8648.117 1998.0351
#> [3,]  -357.8158  1998.035  461.9805