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

Peter Hoff

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,] 26.88628 17.31529 11.61868
#> [2,] 17.31529 33.55156 21.81104
#> [3,] 11.61868 21.81104 39.58705

S0*5
#>          [,1]     [,2]     [,3]
#> [1,] 26.65520 17.55026 11.71500
#> [2,] 17.55026 34.05590 21.66635
#> [3,] 11.71500 21.66635 38.85824