Matrix-variate Distributions
Matrix-variate distributions are the distributions whose variate forms are Matrixvariate
(i.e each sample is a matrix). Abstract types for matrix-variate distributions:
const MatrixDistribution{S<:ValueSupport} = Distribution{Matrixvariate,S}
const DiscreteMatrixDistribution = Distribution{Matrixvariate, Discrete}
const ContinuousMatrixDistribution = Distribution{Matrixvariate, Continuous}
More advanced functionalities related to random matrices can be found in the RandomMatrices.jl package.
Common Interface
All distributions implement the same set of methods:
Base.size
— Method.size(d::MatrixDistribution)
Return the size of each sample from distribution d
.
Base.length
— Method.length(d::MatrixDistribution)
The length (i.e number of elements) of each sample from the distribution d
.
LinearAlgebra.rank
— Method.rank(d::MatrixDistribution)
The rank of each sample from the distribution d
.
Statistics.mean
— Method.mean(d::MatrixDistribution)
Return the mean matrix of d
.
Statistics.var
— Method.var(d::MatrixDistribution)
Compute the matrix of element-wise variances for distribution d
.
Statistics.cov
— Method.cov(d::MatrixDistribution)
Compute the covariance matrix for vec(X)
, where X
is a random matrix with distribution d
.
Distributions.pdf
— Method.pdf(d::MatrixDistribution, x::AbstractArray)
Compute the probability density at the input matrix x
.
Distributions.logpdf
— Method.logpdf(d::MatrixDistribution, AbstractMatrix)
Compute the logarithm of the probability density at the input matrix x
.
Distributions._rand!
— Method._rand!(::AbstractRNG, ::MatrixDistribution, A::AbstractMatrix)
Sample the matrix distribution and store the result in A
. Must be implemented by matrix-variate distributions.
Base.vec
— Method.vec(d::MatrixDistribution)
If known, returns a MultivariateDistribution
instance representing the distribution of vec(X), where X is a random matrix with distribution d
.
Distributions
Distributions.Wishart
— Type.Wishart(ν, S)
ν::Real degrees of freedom (greater than p - 1)
S::PDMat p x p scale matrix
The Wishart distribution generalizes the gamma distribution to $p\times p$ real, positive definite matrices $\mathbf{H}$. If $\mathbf{H}\sim W_p(\nu,\mathbf{S})$, then its probability density function is
If $\nu$ is an integer, then a random matrix $\mathbf{H}$ given by
has $\mathbf{H}\sim W_p(\nu, \mathbf{S})$. For non-integer degrees of freedom, Wishart matrices can be generated via the Bartlett decomposition.
Distributions.InverseWishart
— Type.InverseWishart(ν, Ψ)
ν::Real degrees of freedom (greater than p - 1)
Ψ::PDMat p x p scale matrix
The inverse Wishart distribution generalizes the inverse gamma distribution to $p\times p$ real, positive definite matrices $\boldsymbol{\Sigma}$. If $\boldsymbol{\Sigma}\sim IW_p(\nu,\boldsymbol{\Psi})$, then its probability density function is
$\mathbf{H}\sim W_p(\nu, \mathbf{S})$ if and only if $\mathbf{H}^{-1}\sim IW_p(\nu, \mathbf{S}^{-1})$.
Distributions.MatrixNormal
— Type.MatrixNormal(M, U, V)
M::AbstractMatrix n x p mean
U::PDMat n x n row covariance
V::PDMat p x p column covariance
The matrix normal distribution generalizes the multivariate normal distribution to $n\times p$ real matrices $\mathbf{X}$. If $\mathbf{X}\sim MN_{n,p}(\mathbf{M}, \mathbf{U}, \mathbf{V})$, then its probability density function is
$\mathbf{X}\sim MN_{n,p}(\mathbf{M},\mathbf{U},\mathbf{V})$ if and only if $\text{vec}(\mathbf{X})\sim N(\text{vec}(\mathbf{M}),\mathbf{V}\otimes\mathbf{U})$.
Distributions.MatrixTDist
— Type.MatrixTDist(ν, M, Σ, Ω)
ν::Real positive degrees of freedom
M::AbstractMatrix n x p location
Σ::PDMat n x n scale
Ω::PDMat p x p scale
The matrix t-Distribution generalizes the multivariate t-Distribution to $n\times p$ real matrices $\mathbf{X}$. If $\mathbf{X}\sim MT_{n,p}(\nu,\mathbf{M},\boldsymbol{\Sigma}, \boldsymbol{\Omega})$, then its probability density function is
where
If the joint distribution $p(\mathbf{S},\mathbf{X})=p(\mathbf{S})p(\mathbf{X}|\mathbf{S})$ is given by
then the marginal distribution of $\mathbf{X}$ is $MT_{n,p}(\nu,\mathbf{M},\boldsymbol{\Sigma},\boldsymbol{\Omega})$.
Distributions.MatrixBeta
— Type.MatrixBeta(p, n1, n2)
p::Int dimension
n1::Real degrees of freedom (greater than p - 1)
n2::Real degrees of freedom (greater than p - 1)
The matrix beta distribution generalizes the beta distribution to $p\times p$ real matrices $\mathbf{U}$ for which $\mathbf{U}$ and $\mathbf{I}_p-\mathbf{U}$ are both positive definite. If $\mathbf{U}\sim MB_p(n_1/2, n_2/2)$, then its probability density function is
If $\mathbf{S}_1\sim W_p(n_1,\mathbf{I}_p)$ and $\mathbf{S}_2\sim W_p(n_2,\mathbf{I}_p)$ are independent, and we use $\mathcal{L}(\cdot)$ to denote the lower Cholesky factor, then
has $\mathbf{U}\sim MB_p(n_1/2, n_2/2)$.
Distributions.MatrixFDist
— Type.MatrixFDist(n1, n2, B)
n1::Real degrees of freedom (greater than p - 1)
n2::Real degrees of freedom (greater than p - 1)
B::PDMat p x p scale
The matrix F-Distribution (sometimes called the matrix beta type II distribution) generalizes the F-Distribution to $p\times p$ real, positive definite matrices $\boldsymbol{\Sigma}$. If $\boldsymbol{\Sigma}\sim MF_{p}(n_1/2,n_2/2,\mathbf{B})$, then its probability density function is
If the joint distribution $p(\boldsymbol{\Psi},\boldsymbol{\Sigma})=p(\boldsymbol{\Psi})p(\boldsymbol{\Sigma}|\boldsymbol{\Psi})$ is given by
then the marginal distribution of $\boldsymbol{\Sigma}$ is $MF_{p}(n_1/2,n_2/2,\mathbf{B})$.
Internal Methods (for creating your own matrix-variate distributions)
Distributions._logpdf
— Method._logpdf(d::MatrixDistribution, x::AbstractArray)
Evaluate logarithm of pdf value for a given sample x
. This function need not perform dimension checking.