Multivariate distribution
Wishart distribution
A random positive-definite matrix: the scatter matrix of independent Normal() vectors, so times a sample covariance matrix (about a known zero mean). It is the matrix version of the chi-squared, used for the sampling distribution of covariance estimates and as the conjugate prior for the precision (inverse covariance) matrix of a multivariate normal. The plot shows the case: the joint density of the two diagonal entries , with the off-diagonal entry integrated out.
Joint density of (X₁, X₂)
E[X₁] = 5 · E[X₂] = 5 · Var X₁ = 10 · Var X₂ = 10 · Cov = 3.6 · corr = 0.36
Formulas
| Parameters |
|
|---|---|
| Support | |
| CDF | |
| Mean | |
| Variance |
is the multivariate gamma function, . Each diagonal entry is . For , writing , integrating out gives the plotted density With and the Wishart is the chi-squared with degrees of freedom.
Worked example
Ten independent pairs are drawn from a bivariate normal with mean 0, standard deviations 2 and 1 and correlation 0.5, and . What are the mean and standard deviation of ?
with , so and Dividing by , the variance estimate has mean 4 and standard deviation 1.79: ten points pin a variance down only to within about 45%. answer checked by code
How it relates to others
- Transformation← Multivariate normal: If are independent Normal() vectors, the scatter matrix is Wishart().
- Special case→ Chi-squared: Each diagonal entry of a Wishart() matrix is times a Chi-squared(); with and the Wishart is Chi-squared(). checked by code
- Transformation→ Inverse Wishart: If is Wishart(), its inverse is Inverse Wishart(). checked by code
- Conjugate prior→ Multivariate normal: A Wishart() prior on the precision of a multivariate normal with known mean , and observations , give a Wishart() posterior, where . checked by code
All the relationships, as a diagram →
In Python
from scipy import stats
import numpy as np
X = stats.wishart(df=5, scale=[[1, 0.6], [0.6, 1]])
X.pdf([[5, 3], [3, 5]]) # density here: 0.004364
X.mean()
X.rvs(size=5, random_state=0)
rng = np.random.default_rng(0)
X.rvs(size=5, random_state=rng)X.pdf takes the whole matrix, e.g. X.pdf([[5, 3], [3, 5]]). NumPy has no Wishart sampler; SciPy's rvs takes a NumPy generator as random_state.
Choosing between this and its neighbours? Which prior distribution should I use?