mixle.stats.bayes.normal_wishart module¶
Normal-Wishart distribution over (mu, Lambda) for a d-dimensional Gaussian with unknown mean and precision matrix.
q(mu, Lambda) = N(mu | m, (kappa*Lambda)^{-1}) * Wishart(Lambda | W, nu)
with scale matrix W (d x d positive definite) and degrees of freedom nu > d - 1.
This is the conjugate prior for the multivariate
MultivariateGaussianDistribution (see its prior=
argument) and the d-dimensional generalization of NormalGamma (d=1: nu = 2a,
W = 1/(2b)). It is a parameter prior: it is scored on (mu, Lambda) parameter
pairs, not fit from data by EM.
- class NormalWishartDistribution(mu, kappa, w_mat, nu, name=None, prior=None)[source]
Bases:
SequenceEncodableProbabilityDistributionNormal-Wishart distribution over (mu, Lambda); conjugate prior for the multivariate Gaussian with unknown mean and precision matrix.
- Parameters:
- get_parameters()[source]
Returns the parameter tuple (mu, kappa, w_mat, nu).
- set_parameters(params)[source]
Set the parameters and refresh the cached Wishart log-normalizer.
- Parameters:
params – Tuple (mu, kappa, w_mat, nu) with w_mat positive definite and nu > d - 1.
- Return type:
None
- log_density(x)[source]
Log density at x = (mu, Lambda) with Lambda a precision matrix.
Returns -inf when Lambda is not positive definite.
- Return type:
- cross_entropy(dist)[source]
H(self, dist) = -E_self[log dist] for a NormalWishart argument.
- Parameters:
dist (NormalWishartDistribution)
- Return type:
- entropy()[source]
Returns the entropy of the Normal-Wishart distribution (in nats).
- Return type:
- seq_log_density(x)[source]
Vectorized log-density over a sequence of (mu, Lambda) pairs.
- Return type:
- sampler(seed=None)[source]
Create a NormalWishartSampler for this distribution.
- Parameters:
seed (int | None)
- Return type:
NormalWishartSampler
- estimator(pseudo_count=None)[source]
NormalWishart is a parameter prior and is not fit from data by EM.
- Parameters:
pseudo_count (float | None)
- Return type:
ParameterEstimator
- dist_to_encoder()[source]
Returns a NormalWishartDataEncoder object for encoding (mu, Lambda) pairs.
- Return type:
NormalWishartDataEncoder
- class NormalWishartSampler(dist, seed=None)[source]
Bases:
DistributionSamplerDraws (mu, Lambda) samples from a NormalWishartDistribution.
- Parameters:
dist (NormalWishartDistribution)
seed (int | None)
- scipy_wishart_sample(rng, nu, w_mat)[source]
Draw one Wishart(nu, W) sample via the Bartlett decomposition.
- Parameters:
rng (RandomState)
nu (float)
w_mat (ndarray)
- Return type: