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::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,N}) where {N}
Evaluate the probability density function of d
at x
.
This function checks if the size of x
is compatible with distribution d
. This check can be disabled by using @inbounds
.
Implementation
Instead of pdf
one should implement _pdf(d, x)
which does not have to check the size of x
. However, since the default definition of pdf(d, x)
falls back to logpdf(d, x)
usually it is sufficient to implement logpdf
.
See also: logpdf
.
#
Distributions.logpdf
— Method
logpdf(d::Distribution{ArrayLikeVariate{N}}, x::AbstractArray{<:Real,N}) where {N}
Evaluate the logarithm of the probability density function of d
at x
.
This function checks if the size of x
is compatible with distribution d
. This check can be disabled by using @inbounds
.
Implementation
Instead of logpdf
one should implement _logpdf(d, x)
which does not have to check the size of x
.
See also: pdf
.
Distributions
#
Distributions.MatrixNormal
— Type
MatrixNormal(M, U, V)
M::AbstractMatrix n x p mean
U::AbstractPDMat n x n row covariance
V::AbstractPDMat p x p column covariance
The matrix normal distribution generalizes the multivariate normal distribution to real matrices . If , then its probability density function is
if and only if .
#
Distributions.Wishart
— Type
Wishart(ν, S)
ν::Real degrees of freedom (whole number or a real number greater than p - 1)
S::AbstractPDMat p x p scale matrix
The Wishart distribution generalizes the gamma distribution to real, positive semidefinite matrices .
If , then has rank and its probability density function is
If , then is rank and it has a density with respect to a suitably chosen volume element on the space of positive semidefinite matrices. See here.
For integer , a random matrix given by
has . For non-integer , Wishart matrices can be generated via the Bartlett decomposition.
#
Distributions.InverseWishart
— Type
InverseWishart(ν, Ψ)
ν::Real degrees of freedom (greater than p - 1)
Ψ::AbstractPDMat p x p scale matrix
The inverse Wishart distribution generalizes the inverse gamma distribution to real, positive definite matrices . If , then its probability density function is
if and only if .
#
Distributions.MatrixTDist
— Type
MatrixTDist(ν, M, Σ, Ω)
ν::Real positive degrees of freedom
M::AbstractMatrix n x p location
Σ::AbstractPDMat n x n scale
Ω::AbstractPDMat p x p scale
The matrix t-distribution generalizes the multivariate t-distribution to real matrices . If , then its probability density function is
where
If the joint distribution
then the marginal distribution of
#
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
If
has
#
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::AbstractPDMat p x p scale
The matrix F-distribution (sometimes called the matrix beta type II distribution) generalizes the F-Distribution to
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
#
Distributions.LKJ
— Type
LKJ(d, η)
d::Int dimension
η::Real positive shape
The LKJ distribution is a distribution over
If
if a Cholesky factor of the correlation matrix is desired, it is more efficient to use |