## Wishart Distribution

### Overview

The Wishart distribution is a generalization of the univariate chi-square distribution to two or more variables. It is a distribution for symmetric positive semidefinite matrices, typically covariance matrices, the diagonal elements of which are each chi-square random variables. In the same way as the chi-square distribution can be constructed by summing the squares of independent, identically distributed, zero-mean univariate normal random variables, the Wishart distribution can be constructed by summing the inner products of independent, identically distributed, zero-mean multivariate normal random vectors. The Wishart distribution is often used as a model for the distribution of the sample covariance matrix for multivariate normal random data, after scaling by the sample size.

Only random matrix generation is supported for the Wishart distribution, including
both singular and nonsingular *Σ*.

### Parameters

The Wishart distribution is parameterized with a symmetric, positive semidefinite
matrix, *Σ*, and a positive scalar degrees of freedom parameter,
*ν*. *ν* is analogous to the degrees of
freedom parameter of a univariate chi-square distribution, and *Σν*
is the mean of the distribution.

### Probability Density Function

The probability density function of the *d*-dimensional Wishart
distribution is given by

$$\text{y=f(}{\rm X}\text{,}\Sigma \text{,}\nu \text{)=}\frac{{\left|{\rm X}\right|}^{\left(\text{(}\nu \text{-d-1})/2\right)}{e}^{\left(\text{-}\frac{1}{2}\text{trace}\left({\Sigma}^{-1}{\rm X}\right)\right)}}{{\text{2}}^{\text{(}\nu \text{d)/2}}{\pi}^{\text{(d(d-1))/4}}{|\sum |}^{\nu /2}\Gamma \left(\nu /2\right)\mathrm{...}\Gamma \text{(}\nu \text{-(d-1))/2}}$$

where *X* and *Σ* are
*d*-by-*d* symmetric positive definite
matrices, and *v* is a scalar greater than *d* –
1. While it is possible to define the Wishart for singular *Σ*, the
density cannot be written as above.

### Example

If *x* is a bivariate normal random vector with mean zero and
covariance matrix

$$\Sigma =\left(\begin{array}{cc}1& .5\\ .5& 2\end{array}\right)$$

then you can use the Wishart distribution to generate a sample covariance matrix
without explicitly generating *x* itself. Notice how the sampling
variability is quite large when the degrees of freedom is small.

Sigma = [1 .5; .5 2]; df = 10; S1 = wishrnd(Sigma,df)/df S1 = 1.7959 0.64107 0.64107 1.5496 df = 1000; S2 = wishrnd(Sigma,df)/df S2 = 0.9842 0.50158 0.50158 2.1682