Skip to contents

Simulates a random Wishart-distributed matrix

Usage

rwish(S0, nu = dim(S0)[1] + 2)

Arguments

S0

a positive definite matrix

nu

a positive integer

Value

a positive definite matrix

Author

lame authors

Examples


## The expectation is S0*nu

S0<-rwish(diag(3))

SS<-matrix(0,3,3)
for(s in 1:1000) { SS<-SS+rwish(S0,5) }

SS/s
#>           [,1]      [,2]      [,3]
#> [1,] 11.687168 -3.431727  2.872217
#> [2,] -3.431727 17.575789  2.385297
#> [3,]  2.872217  2.385297 39.896096

S0*5
#>           [,1]      [,2]      [,3]
#> [1,] 11.829316 -3.361971  2.225789
#> [2,] -3.361971 17.496889  2.326030
#> [3,]  2.225789  2.326030 39.301594