# Inverse-Wishart distribution

In statistics, the inverse Wishart distribution, also called the inverted Wishart distribution, is a probability distribution defined on real-valued positive-definite matrices. In Bayesian statistics it is used as the conjugate prior for the covariance matrix of a multivariate normal distribution.

Notation ${\mathcal {W}}^{-1}({\mathbf {\Psi } },\nu )$ $\nu >p-1$ degrees of freedom (real)$\mathbf {\Psi } >0$ , $p\times p$ scale matrix (pos. def.) $\mathbf {X}$ is p × p positive definite ${\frac {\left|\mathbf {\Psi } \right|^{\nu /2}}{2^{\nu p/2}\Gamma _{p}({\frac {\nu }{2}})}}\left|\mathbf {x} \right|^{-(\nu +p+1)/2}e^{-{\frac {1}{2}}\operatorname {tr} (\mathbf {\Psi } \mathbf {x} ^{-1})}$ $\Gamma _{p}$ is the multivariate gamma function $\operatorname {tr}$ is the trace function ${\frac {\mathbf {\Psi } }{\nu -p-1}}$ For $\nu >p+1$ ${\frac {\mathbf {\Psi } }{\nu +p+1}}$ :406 see below

We say $\mathbf {X}$ follows an inverse Wishart distribution, denoted as $\mathbf {X} \sim {\mathcal {W}}^{-1}(\mathbf {\Psi } ,\nu )$ , if its inverse $\mathbf {X} ^{-1}$ has a Wishart distribution ${\mathcal {W}}(\mathbf {\Psi } ^{-1},\nu )$ . Important identities have been derived for the inverse-Wishart distribution.

## Density

The probability density function of the inverse Wishart is:

$f_{\mathbf {x} }({\mathbf {x} };{\mathbf {\Psi } },\nu )={\frac {\left|{\mathbf {\Psi } }\right|^{\nu /2}}{2^{\nu p/2}\Gamma _{p}({\frac {\nu }{2}})}}\left|\mathbf {x} \right|^{-(\nu +p+1)/2}e^{-{\frac {1}{2}}\operatorname {tr} (\mathbf {\Psi } \mathbf {x} ^{-1})}$

where $\mathbf {x}$  and ${\mathbf {\Psi } }$  are $p\times p$  positive definite matrices, and Γp(·) is the multivariate gamma function.

## Theorems

### Distribution of the inverse of a Wishart-distributed matrix

If ${\mathbf {A} }\sim {\mathcal {W}}({\mathbf {\Sigma } },\nu )$  and ${\mathbf {\Sigma } }$  is of size $p\times p$ , then $\mathbf {X} ={\mathbf {A} }^{-1}$  has an inverse Wishart distribution $\mathbf {X} \sim {\mathcal {W}}^{-1}({\mathbf {\Sigma } }^{-1},\nu )$  .

### Marginal and conditional distributions from an inverse Wishart-distributed matrix

Suppose ${\mathbf {A} }\sim {\mathcal {W}}^{-1}({\mathbf {\Psi } },\nu )$  has an inverse Wishart distribution. Partition the matrices ${\mathbf {A} }$  and ${\mathbf {\Psi } }$  conformably with each other

${\mathbf {A} }={\begin{bmatrix}\mathbf {A} _{11}&\mathbf {A} _{12}\\\mathbf {A} _{21}&\mathbf {A} _{22}\end{bmatrix}},\;{\mathbf {\Psi } }={\begin{bmatrix}\mathbf {\Psi } _{11}&\mathbf {\Psi } _{12}\\\mathbf {\Psi } _{21}&\mathbf {\Psi } _{22}\end{bmatrix}}$

where ${\mathbf {A} _{ij}}$  and ${\mathbf {\Psi } _{ij}}$  are $p_{i}\times p_{j}$  matrices, then we have

i) $\mathbf {A} _{11}$  is independent of $\mathbf {A} _{11}^{-1}\mathbf {A} _{12}$  and ${\mathbf {A} }_{22\cdot 1}$ , where ${\mathbf {A} _{22\cdot 1}}={\mathbf {A} }_{22}-{\mathbf {A} }_{21}{\mathbf {A} }_{11}^{-1}{\mathbf {A} }_{12}$  is the Schur complement of ${\mathbf {A} _{11}}$  in ${\mathbf {A} }$ ;

ii) ${\mathbf {A} _{11}}\sim {\mathcal {W}}^{-1}({\mathbf {\Psi } _{11}},\nu -p_{2})$ ;

iii) ${\mathbf {A} }_{11}^{-1}{\mathbf {A} }_{12}\mid {\mathbf {A} }_{22\cdot 1}\sim MN_{p_{1}\times p_{2}}({\mathbf {\Psi } }_{11}^{-1}{\mathbf {\Psi } }_{12},{\mathbf {A} }_{22\cdot 1}\otimes {\mathbf {\Psi } }_{11}^{-1})$ , where $MN_{p\times q}(\cdot ,\cdot )$  is a matrix normal distribution;

iv) ${\mathbf {A} }_{22\cdot 1}\sim {\mathcal {W}}^{-1}({\mathbf {\Psi } }_{22\cdot 1},\nu )$ , where ${\mathbf {\Psi } _{22\cdot 1}}={\mathbf {\Psi } }_{22}-{\mathbf {\Psi } }_{21}{\mathbf {\Psi } }_{11}^{-1}{\mathbf {\Psi } }_{12}$ ;

### Conjugate distribution

Suppose we wish to make inference about a covariance matrix ${\mathbf {\Sigma } }$  whose prior ${p(\mathbf {\Sigma } )}$  has a ${\mathcal {W}}^{-1}({\mathbf {\Psi } },\nu )$  distribution. If the observations $\mathbf {X} =[\mathbf {x} _{1},\ldots ,\mathbf {x} _{n}]$  are independent p-variate Gaussian variables drawn from a $N(\mathbf {0} ,{\mathbf {\Sigma } })$  distribution, then the conditional distribution ${p(\mathbf {\Sigma } \mid \mathbf {X} )}$  has a ${\mathcal {W}}^{-1}({\mathbf {A} }+{\mathbf {\Psi } },n+\nu )$  distribution, where ${\mathbf {A} }=\mathbf {X} \mathbf {X} ^{T}$ .

Because the prior and posterior distributions are the same family, we say the inverse Wishart distribution is conjugate to the multivariate Gaussian.

Due to its conjugacy to the multivariate Gaussian, it is possible to marginalize out (integrate out) the Gaussian's parameter $\mathbf {\Sigma }$ .

$f_{\mathbf {X} \,\mid \,\Psi ,\nu }(\mathbf {x} )=\int f_{\mathbf {X} \,\mid \,\mathbf {\Sigma } \,=\,\sigma }(\mathbf {x} )f_{\mathbf {\Sigma } \,\mid \,\mathbf {\Psi } ,\nu }(\sigma )\,d\sigma ={\frac {|\mathbf {\Psi } |^{\nu /2}\Gamma _{p}\left({\frac {\nu +n}{2}}\right)}{\pi ^{np/2}|\mathbf {\Psi } +\mathbf {A} |^{(\nu +n)/2}\Gamma _{p}({\frac {\nu }{2}})}}$

(this is useful because the variance matrix $\mathbf {\Sigma }$  is not known in practice, but because ${\mathbf {\Psi } }$  is known a priori, and ${\mathbf {A} }$  can be obtained from the data, the right hand side can be evaluated directly). The inverse-Wishart distribution as a prior can be constructed via existing transferred prior knowledge.

### Moments

The following is based on Press, S. J. (1982) "Applied Multivariate Analysis", 2nd ed. (Dover Publications, New York), after reparameterizing the degree of freedom to be consistent with the p.d.f. definition above.

The mean::85

$\operatorname {E} (\mathbf {X} )={\frac {\mathbf {\Psi } }{\nu -p-1}}.$

The variance of each element of $\mathbf {X}$ :

$\operatorname {Var} (x_{ij})={\frac {(\nu -p+1)\psi _{ij}^{2}+(\nu -p-1)\psi _{ii}\psi _{jj}}{(\nu -p)(\nu -p-1)^{2}(\nu -p-3)}}$

The variance of the diagonal uses the same formula as above with $i=j$ , which simplifies to:

$\operatorname {Var} (x_{ii})={\frac {2\psi _{ii}^{2}}{(\nu -p-1)^{2}(\nu -p-3)}}.$

The covariance of elements of $\mathbf {X}$  are given by:

$\operatorname {Cov} (x_{ij},x_{k\ell })={\frac {2\psi _{ij}\psi _{k\ell }+(\nu -p-1)(\psi _{ik}\psi _{j\ell }+\psi _{i\ell }\psi _{kj})}{(\nu -p)(\nu -p-1)^{2}(\nu -p-3)}}$

It was shown by Brennan and Reed using a matrix partitioning procedure, albeit in the complex variable domain, that the marginal pdf of the [1,1] diagonal element of the inverse Wishart ${\mathcal {W}}^{-1}(\mathbf {I} ,\nu ,p)$  has an Inverse-chi-squared distribution. For the inverse Chi squared distribution, with arbitrary $\nu _{c}$  degrees of freedom, the pdf is

${\text{Inv-}}\chi ^{2}(x;\nu _{c})={\frac {2^{-\nu _{c}/2}}{\Gamma (\nu _{c}/2)}}x^{-\nu _{c}/2-1}e^{-1/(2x)}.$

the mean and variance of which are ${\frac {1}{\nu _{c}-2}}{\text{ and }}{\frac {2}{(\nu _{c}-2)^{2}(\nu _{c}-4)}}$  respectively. These two parameters are matched to the corresponding inverse Wishart diagonal moments when $\nu _{c}=\nu -p+1$  and hence the diagonal element marginal pdf of ${\mathcal {W}}^{-1}(\mathbf {I} ,\nu ,p)$  becomes:

$f_{x_{11}}(x_{11};\Psi ,\nu ,p)={\frac {2^{-(\nu -p+1)/2}}{\Gamma \left({\frac {\nu -p+1}{2}}\right)}}\,x_{11}^{-(\nu -p+1)/2-1}e^{-1/(2x_{11})}$

which, below, is generalized to all diagonal elements.

## Related distributions

A univariate specialization of the inverse-Wishart distribution is the inverse-gamma distribution. With $p=1$  (i.e. univariate) and $\alpha =\nu /2$ , $\beta =\mathbf {\Psi } /2$  and $x=\mathbf {X}$  the probability density function of the inverse-Wishart distribution becomes

$p(x\mid \alpha ,\beta )={\frac {\beta ^{\alpha }\,x^{-\alpha -1}\exp(-\beta /x)}{\Gamma _{1}(\alpha )}}.$

i.e., the inverse-gamma distribution, where $\Gamma _{1}(\cdot )$  is the ordinary Gamma function.

The Inverse Wishart distribution is a special case of the inverse matrix gamma distribution when the shape parameter $\alpha ={\frac {\nu }{2}}$  and the scale parameter $\beta =2$ .

Another generalization has been termed the generalized inverse Wishart distribution, ${\mathcal {GW}}^{-1}$ . A $p\times p$  positive definite matrix $\mathbf {X}$  is said to be distributed as ${\mathcal {GW}}^{-1}(\mathbf {\Psi } ,\nu ,\mathbf {S} )$  if $\mathbf {Y} =\mathbf {X} ^{1/2}\mathbf {S} ^{-1}\mathbf {X} ^{1/2}$  is distributed as ${\mathcal {W}}^{-1}(\mathbf {\Psi } ,\nu )$ . Here $\mathbf {X} ^{1/2}$  denotes the symmetric matrix square root of $\mathbf {X}$ , the parameters $\mathbf {\Psi } ,\mathbf {S}$  are $p\times p$  positive definite matrices, and the parameter $\nu$  is a positive scalar larger than $2p$ . Note that when $\mathbf {S}$  is equal to an identity matrix, ${\mathcal {GW}}^{-1}(\mathbf {\Psi } ,\nu ,\mathbf {S} )={\mathcal {W}}^{-1}(\mathbf {\Psi } ,\nu )$ . This generalized inverse Wishart distribution has been applied to estimating the distributions of multivariate autoregressive processes.

A different type of generalization is the normal-inverse-Wishart distribution, essentially the product of a multivariate normal distribution with an inverse Wishart distribution.

When the scale matrix is an identity matrix, ${\mathcal {\Psi }}=\mathbf {I} ,{\text{ and }}{\mathcal {\Phi }}$  is an arbitrary orthogonal matrix, replacement of $\mathbf {X}$  by ${\Phi }\mathbf {X} {\mathcal {\Phi }}^{T}$  does not change the pdf of $\mathbf {X}$  so ${\mathcal {W}}^{-1}(\mathbf {I} ,\nu ,p)$  belongs to the family of spherically invariant random processes (SIRPs) in some sense.
Thus, an arbitrary p-vector $V$  with $l_{2}{\text{ length }}V^{T}V=1$  can be rotated into the vector $\mathbf {\Phi } V=[1\;0\;0\cdots ]^{T}$  without changing the pdf of $V^{T}\mathbf {X} V$ , moreover $\mathbf {\Phi }$  can be a permutation matrix which exchanges diagonal elements. It follows that the diagonal elements of $\mathbf {X}$  are identically inverse chi squared distributed, with pdf $f_{x_{11}}$  in the previous section though they are not mutually independent. The result is known in optimal portfolio statistics, as in Theorem 2 Corollary 1 of Bodnar et al, where it is expressed in the inverse form ${\frac {V^{T}\mathbf {\Psi } V}{V^{T}\mathbf {X} V}}\sim \chi _{\nu -p+1}^{2}$ .