Gaussian#

class hybrid_aif.Gaussian[source]#

Bases: ExponentialFamily

A multivariate Gaussian with full covariance, batched over leading axes.

Stored as the mean loc and a lower-triangular Cholesky factor chol (log-determinants and solves read off the factor); the event shape is (dim,). from_cov() builds one from a covariance, cov returns it, kl_to() is the closed form (a MixtureGaussian other is handled through the mixture bounds), and the natural view is eta1 = Σ⁻¹ μ, eta2 = -0.5 Σ⁻¹.

loc: Array#

The mean, (..., dim).

chol: Array#

The lower-triangular Cholesky factor of the covariance, (..., dim, dim). A preference over a modality may instead give a diagonal standard deviation, the shape of loc (diagonal; dense() expands it).

property batch_shape: tuple[int, ...]#

Leading (batch) axes: leaf shape minus the family’s fixed trailing structure.

property diagonal: bool#

Whether chol is a diagonal standard deviation (..., dim), the shape of loc (a full factor has one trailing axis more). Only a preference over a modality reads it as such; every other method needs dense().

dense()[source]#

The Gaussian with a full (..., dim, dim) factor (itself when it has one).

log_prob(x)[source]#

Log density/mass at x; broadcasts over batch axes.

sample(key, sample_shape=())[source]#

Draw samples with shape sample_shape + batch_shape + event_shape.

mean()[source]#

Mean (moment view).

entropy()[source]#

Differential/discrete entropy as an Interval (zero-width when exact).

kl_to(other)[source]#

Closed-form Gaussian KL, computed via Cholesky solves.

A MixtureGaussian other is handled by promoting self to a 1-component mixture and using the mixture bounds.

natural()[source]#

Natural parameters as a tuple of arrays (gauge documented per class).

classmethod from_natural(eta1, eta2)[source]#

Inverse of natural(), up to gauge and float error.

__init__(loc, chol)#