# Library API

## Additional distributions

These are the distributions that are not included in the Distributions.jl package.

`ExponentialFamily.MatrixDirichlet`

— Type`MatrixDirichlet{T <: Real, A <: AbstractMatrix{T}} <: ContinuousMatrixDistribution`

A matrix-valued MatrixDirichlet distribution, where `T`

is the element type of the matrix `A`

. The `a`

field stores the matrix parameter of the distribution.

**Fields**

`a::A`

: The matrix parameter of the MatrixDirichlet distribution.

`ExponentialFamily.GammaShapeRate`

— Type`GammaShapeRate{T <: Real}`

A univariate gamma distribution parametrized by its shape `a`

and rate `b`

.

**Fields**

`a`

: The shape parameter of the gamma distribution. It should be a positive real number.`b`

: The rate parameter of the gamma distribution. It should be a positive real number.

`ExponentialFamily.GammaShapeScale`

— Type`GammaShapeScale{T}`

A continuous univariate gamma distribution parametrized by its shape `α`

and scale `β`

parameters.

**Fields**

`α`

: The shape parameter of the gamma distribution. It should be a positive real number.`β`

: The scale parameter of the gamma distribution. It should be a positive real number.

**Note**

- GammaShapeScale is an alias for Gamma from Distributions.jl.

`ExponentialFamily.NormalMeanPrecision`

— Type`NormalMeanPrecision{T <: Real} <: ContinuousUnivariateDistribution`

A normal distribution with a known mean `μ`

and precision `w`

.

**Fields**

`μ::T`

: The mean of the normal distribution.`w::T`

: The precision of the normal distribution.

`ExponentialFamily.NormalMeanVariance`

— Type`NormalMeanVariance{T <: Real} <: ContinuousUnivariateDistribution`

A normal distribution with a known mean `μ`

and variance `v`

.

**Fields**

`μ::T`

: The mean of the normal distribution.`v::T`

: The variance of the normal distribution.

`ExponentialFamily.NormalWeightedMeanPrecision`

— Type`NormalWeightedMeanPrecision{T <: Real} <: ContinuousUnivariateDistribution`

A normal distribution parametrized by its natural parameters: the weighted mean `xi`

and precision `w`

.

**Fields**

`xi::T`

: The weighted mean of the normal distribution.`xi`

is computed as`w * μ`

, where`μ`

is the mean of the distribution.`w::T`

: The precision (inverse variance) of the normal distribution.

`ExponentialFamily.MvNormalMeanPrecision`

— Type`MvNormalMeanPrecision{T <: Real, M <: AbstractVector{T}, P <: AbstractMatrix{T}} <: AbstractMvNormal`

A multivariate normal distribution with mean `μ`

and precision matrix `Λ`

, where `T`

is the element type of the vectors `M`

and matrices `P`

.

**Fields**

`μ::M`

: The mean vector of the multivariate normal distribution.`Λ::P`

: The precision matrix (inverse of the covariance matrix) of the multivariate normal distribution.

`ExponentialFamily.MvNormalMeanCovariance`

— Type`MvNormalMeanCovariance{T <: Real, M <: AbstractVector{T}, P <: AbstractMatrix{T}} <: AbstractMvNormal`

A multivariate normal distribution with mean `μ`

and covariance matrix `Σ`

, where `T`

is the element type of the vectors `M`

and matrices `P`

.

**Fields**

`μ::M`

: The mean vector of the multivariate normal distribution.`Σ::P`

: The covariance matrix of the multivariate normal distribution

`ExponentialFamily.MvNormalWeightedMeanPrecision`

— Type`MvNormalWeightedMeanPrecision{T <: Real, M <: AbstractVector{T}, P <: AbstractMatrix{T}} <: AbstractMvNormal`

A multivariate normal distribution with a weighted mean vector `xi`

and precision matrix `Λ`

, where `T`

is the element type of the vectors `M`

and matrices `P`

. This struct represents a natural parametrization of a multivariate Gaussian distribution.

**Fields**

`xi::M`

: The weighted mean vector of the multivariate normal distribution.`Λ::P`

: The precision matrix (inverse of the covariance matrix) of the multivariate normal distribution.

`ExponentialFamily.JointNormal`

— Type`JointNormal{D, S}`

`JointNormal`

is an auxilary structure used for the joint marginal over Normally distributed variables. `JointNormal`

stores a vector with the original dimensionalities (ds), so statistics can later be re-separated.

Use `ExponentialFamily.getcomponent(joint, index)`

to get a specific component of the joint distribution.

**Fields**

`dist`

: joint distribution (typically just a big`MvNormal`

distribution, but maybe a tuple of individual means and covariance matrices)`ds`

: a tuple with the original dimensionalities of individual`Normal`

distributions`ds[k] = (n,)`

where`n`

is an integer indicates`Multivariate`

normal of size`n`

`ds[k] = ()`

indicates`Univariate`

normal

`ExponentialFamily.JointGaussian`

— TypeAn alias for the `JointNormal`

.

`ExponentialFamily.WishartFast`

— Type`WishartFast{T <: Real, A <: AbstractMatrix{T}} <: ContinuousMatrixDistribution`

The `WishartFast`

struct represents a fast version of the Wishart distribution. It is similar to the `Wishart`

distribution from `Distributions.jl`

, but it does not check input arguments, allowing the creation of improper `Wishart`

messages.

For model creation and regular usage, it is recommended to use `Wishart`

from `Distributions.jl`

. The `WishartFast`

distribution is intended for internal purposes and should not be directly used by regular users.

**Fields**

`ν::T`

: The degrees of freedom parameter of the Wishart distribution.`invS::A`

: The inverse scale matrix parameter of the Wishart distribution.

**Note**

Internally, `WishartFast`

stores and creates the inverse of its scale matrix. However, the `params()`

function returns the scale matrix itself for backward compatibility. This is done to ensure better stability in the message passing update rules for `ReactiveMP.jl`

.

`ExponentialFamily.InverseWishartFast`

— Type`InverseWishartFast{T <: Real, A <: AbstractMatrix{T}} <: ContinuousMatrixDistribution`

The `InverseWishartFast`

struct represents an improper Inverse Wishart distribution. It is similar to the `InverseWishart`

distribution from `Distributions.jl`

, but it does not check input arguments, allowing the creation of improper `InverseWishart`

messages.

For model creation and regular usage, it is recommended to use `InverseWishart`

from `Distributions.jl`

. The `InverseWishartFast`

distribution is intended for internal purposes and should not be directly used by regular users.

**Fields**

`ν::T`

: The degrees of freedom parameter of the inverse Wishart distribution.`S::A`

: The scale matrix parameter of the inverse Wishart distribution.

**Note**

The `InverseWishartFast`

distribution does not enforce input argument validation, making it suitable for specialized cases where improper message constructions are needed.

`ExponentialFamily.NormalGamma`

— Type`NormalGamma{T <: Real} <: ContinuousMultivariateDistribution`

A normal-gamma distribution, where `T`

is a real number. This distribution is a joint distribution of a normal random variable with mean `μ`

and precision `λ`

, and a gamma-distributed random variable with shape `α`

and rate `β`

.

**Fields**

`μ::T`

: The mean of the normal distribution.`λ::T`

: The precision of the normal distribution.`α::T`

: The shape parameter of the gamma distribution.`β::T`

: The rate parameter of the gamma distribution.

`ExponentialFamily.MvNormalWishart`

— Type`MvNormalWishart{T, M <: AbstractArray{T}, V <: AbstractMatrix{T}, K <: Real, N <: Real} <: ContinuousMatrixDistribution`

A multivariate normal-Wishart distribution, where `T`

is the element type of the arrays `M`

and matrices `V`

, and `K`

and `N`

are real numbers. This distribution is a joint distribution of a multivariate normal random variable with mean `μ`

and a Wishart-distributed random matrix with scale matrix `Ψ`

, degrees of freedom `ν`

, and the scalar `κ`

as a scaling parameter.

**Fields**

`μ::M`

: The mean vector of the multivariate normal distribution.`Ψ::V`

: The scale matrix of the Wishart distribution.`κ::K`

: The scaling parameter of the Wishart distribution.`ν::N`

: The degrees of freedom of the Wishart distribution