bartz.mcmcstep.Wishart

class bartz.mcmcstep.Wishart(nu, rate, value)[source]

A precision matrix with a Wishart prior, bundled with its current value.

Represents a random precision (inverse covariance) value drawn from a Wishart prior with degrees of freedom nu and rate matrix rate. The univariate case (k = 1) is the Gamma special case; the relationship to the inverse-gamma prior on the variance is alpha = nu / 2, beta = rate / 2. The prior mean of the precision is nu * rate^-1. Each marginal error variance (diagonal of the inverse) is inverse-gamma with alpha = inv_wishart_marginal_nu / 2, beta = rate_ii / 2.

Set nu and rate to None to represent a precision held fixed at value with no prior (e.g. the identity in binary regression).

nu: Float32[Array, ''] | None

Degrees of freedom of the Wishart prior, or None if there is no prior.

rate: Float32[Array, ''] | Float32[Array, 'k k'] | None

The rate matrix of the Wishart prior (scalar for univariate), or None if there is no prior. Equal to the inverse-gamma scale in the univariate case.

value: Float32[Array, '*chains k k'] | Float32[Array, '*chains']

The precision matrix (scalar for univariate).

classmethod from_inv_wishart_marginal_nu(marginal_nu, rate, value)[source]

Build the prior from the degrees of freedom of each marginal variance.

Sets nu = marginal_nu + k - 1, the inverse of inv_wishart_marginal_nu.

Return type:

Wishart

property inv_wishart_marginal_nu: Float32[Array, ''] | None[source]

Degrees of freedom of the inverse-gamma marginal of each variance.

Equal to nu - k + 1, or None if there is no prior.