Generate n
random matrices, distributed according to the
Wishart distribution with parameters Sigma
and df
,
rWishart(n, df, Sigma)
integer sample size.
numeric parameter, “degrees of freedom”.
positive definite (
a numeric array
, say R
, of dimension
R[,,i]
is a
positive definite matrix, a realization of the Wishart distribution
If
Consequently, the expectation of Sigma
is scalar (df
degrees of freedom,
The component wise variance is
Mardia, K. V., J. T. Kent, and J. M. Bibby (1979) Multivariate Analysis, London: Academic Press.
# NOT RUN {
## Artificial
S <- toeplitz((10:1)/10)
set.seed(11)
R <- rWishart(1000, 20, S)
dim(R) # 10 10 1000
mR <- apply(R, 1:2, mean) # ~= E[ Wish(S, 20) ] = 20 * S
stopifnot(all.equal(mR, 20*S, tolerance = .009))
## See Details, the variance is
Va <- 20*(S^2 + tcrossprod(diag(S)))
vR <- apply(R, 1:2, var)
stopifnot(all.equal(vR, Va, tolerance = 1/16))
# }
Run the code above in your browser using DataLab