Project Status: Active – The project has reached a stable, usable
state and is being actively
developed. AppVeyor Build
Status codecov R build
status Licence lifecycle

minimal R
version CRAN_Status_Badge packageversion



The most common use for this package is likely fast sampling from the inverse Wishart or use of the multivariate gamma or digamma functions. This is a package for fast computation of various functions related to the Wishart distribution, such as sampling from the Cholesky factorization of the Wishart, sampling from the inverse Wishart, sampling from the Cholesky factorization of the inverse Wishart, sampling from the pseudo Wishart, computing densities for the Wishart and inverse Wishart, and computing a few auxiliary functions such as the multivariate gamma and digamma functions. Many of these functions are written in C to maximize efficiency.

The output of the sampling functions is in the same format as the output of stats::rWishart().

The main idea: sampling for multivariate or matrix variate statistics often makes use of distributions related to the Wishart. There are implementations in a few packages but they are often in R and much slower than the basic stats::rWishart() or there is a lot of associated overhead in the package. Here, then, is a small package with some of those distributions and related functions. As the name suggests, the initial purpose was sampling from the Cholesky factorization of a Wishart distribution.


The package offers the following distributions:

rInvWishart(n = 1,df = 5,Sigma = diag(4)))
rInvCholWishart(n = 1,df = 5,Sigma = diag(4)))
rCholWishart(n = 1,df = 5,Sigma = diag(4)))
rPseudoWishart(n = 1,df = 3,Sigma = diag(5)))
rGenInvWishart(n = 1,df = 3,Sigma = diag(5)))
dInvWishart(x = diag(4), df = 5, Sigma = diag(4), log = TRUE)
dWishart(x = diag(4), df = 5, Sigma = diag(4), log = TRUE)

In addition to this, the package offers the multivariate gamma function and multivariate digamma function, the multivariate counterparts of the gamma and digamma (derivative of the log of the gamma) functions.

mvgamma(x = 5, p = 3)
mvdigamma(x = 5, p = 3)

I suspect the most useful functions for most people will be the mvgamma and rInvWishart functions.


Now available on CRAN, install it at:


Install the latest development version at:

# install.packages('devtools')

Calling from other packages

The header inst/install/CholWishart.h is available so that the exported functions can be called in C from other packages.


Please note that the ‘CholWishart’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

Try the CholWishart package in your browser

Any scripts or data that you put into this service are public.

CholWishart documentation built on Oct. 8, 2021, 9:09 a.m.