rGenInvWishart {CholWishart}R Documentation

Random Generalized Inverse Wishart Distributed Matrices


Generate n random matrices, distributed according to the generalized inverse Wishart distribution with parameters Sigma and df, W_p(Sigma, df), with sample size df less than the dimension p.

Let X_i, i = 1, 2, ..., df be df observations of a multivariate normal distribution with mean 0 and covariance Sigma. Then ∑ X_i X_i' is distributed as a pseudo Wishart W_p(Sigma, df). Sometimes this is called a singular Wishart distribution, however, that can be confused with the case where Sigma itself is singular. Then the generalized inverse Wishart distribution is the natural extension of the inverse Wishart using the Moore-Penrose pseudo-inverse. This can generate samples for positive semi-definite Sigma however, a function dedicated to generating singular normal random distributions or singular pseudo Wishart distributions should be used if that is desired.

Note there are different ways of parameterizing the Inverse Wishart distribution, so check which one you need. Here, if X ~ IW_p(Sigma, df) then X^{-1} ~ W_p(Sigma^{-1}, df). Dawid (1981) has a different definition: if X ~ W_p(Sigma^{-1}, df) and df > p - 1, then X^{-1} = Y ~ IW(Sigma, delta), where delta = df - p + 1.


rGenInvWishart(n, df, Sigma)



integer sample size.


integer parameter, "degrees of freedom", should be less than the dimension of p


positive semi-definite (p * p) "scale" matrix, the matrix parameter of the distribution.


a numeric array, say R, of dimension p * p * n, where each R[,,i] is a realization of the pseudo Wishart distribution W_p(Sigma, df).


Diaz-Garcia, Jose A, Ramon Gutierrez Jaimez, and Kanti V Mardia. 1997. “Wishart and Pseudo-Wishart Distributions and Some Applications to Shape Theory.” Journal of Multivariate Analysis 63 (1): 73–87. doi: 10.1006/jmva.1997.1689.

Bodnar, T., Mazur, S., Podgórski, K. "Singular inverse Wishart distribution and its application to portfolio theory", Journal of Multivariate Analysis, Volume 143, 2016, Pages 314-326, ISSN 0047-259X, doi: 10.1016/j.jmva.2015.09.021.

Bodnar, T., Okhrin, Y., "Properties of the singular, inverse and generalized inverse partitioned Wishart distributions", Journal of Multivariate Analysis, Volume 99, Issue 10, 2008, Pages 2389-2405, ISSN 0047-259X, doi: 10.1016/j.jmva.2008.02.024.

Uhlig, Harald. On Singular Wishart and Singular Multivariate Beta Distributions. Ann. Statist. 22 (1994), no. 1, 395–405. doi: 10.1214/aos/1176325375.

See Also

rWishart, rInvWishart, and rPseudoWishart


A<-rGenInvWishart(1L, 4L, 5.0*diag(5L))[,,1]
# A should be singular
B <- rPseudoWishart(1L, 4L, 5.0*diag(5L))[,,1]

# A should be a Moore-Penrose pseudo-inverse of B
# this should be equal to B
B %*% A %*% B
# this should be equal to A
A %*% B %*% A

[Package CholWishart version 1.1.0 Index]