Combinators

Combinators for composing exponential families: location-shape products and replicated (independent) products.

Class Hierarchy

Inheritance diagram of goal.geometry.exponential_family.combinators

Location-Shape Models

class LocationShape[source]

Bases: Pair, ExponentialFamily, ABC, Generic

A product of location and shape exponential families sharing the same data space.

Used for distributions like the Normal that decompose into a location component (e.g. mean vector) and a shape component (e.g. covariance matrix). The sufficient statistic concatenates both components; the base measure comes from the shape component.

property data_dim: int

Dimension of the data space.

sufficient_statistic(x: Array) Array[source]

Compute the sufficient statistic \(\mathbf{s}(x)\) of an observation.

initialize(key: Array, location: float = 0.0, shape: float = 0.1) Array[source]

Generate random natural parameters from a Gaussian perturbation.

log_base_measure(x: Array) Array[source]

Compute \(\log \mu(x)\) for an observation.

Product Models

class Product(rep_man: M, n_reps: int)[source]

Bases: Replicated, ExponentialFamily, Generic

Product of n_reps independent copies of the same exponential family.

The sufficient statistic and base measure decompose across replicates. If the base family supports StatisticalMoments, the product exposes composed mean and block-diagonal covariance.

property data_dim: int

Dimension of the data space.

sufficient_statistic(x: Array) Array[source]

Compute the sufficient statistic \(\mathbf{s}(x)\) of an observation.

log_base_measure(x: Array) Array[source]

Compute \(\log \mu(x)\) for an observation.

initialize(key: Array, location: float = 0.0, shape: float = 0.1) Array[source]

Generate random natural parameters from a Gaussian perturbation.

initialize_from_sample(key: Array, sample: Array, location: float = 0.0, shape: float = 0.1) Array[source]

Generate random natural parameters, optionally informed by data.

Default: ignores the sample. Analytic overrides this to use average sufficient statistics.

statistical_mean(params: Array) Array[source]

Compute the mean of the product distribution from its natural parameters.

Requires the base family to satisfy StatisticalMoments.

statistical_covariance(params: Array) Array[source]

Compute the block-diagonal covariance of the product distribution from its natural parameters.

Requires the base family to satisfy StatisticalMoments.

class GenerativeProduct(rep_man: M, n_reps: int)[source]

Bases: Product, Generative, Generic

Product of generative exponential families, adding independent sampling across replicates.

sample(key: Array, params: Array, n: int = 1) Array[source]

Draw n samples from the product distribution given its natural parameters.

class DifferentiableProduct(rep_man: M, n_reps: int)[source]

Bases: Differentiable, GenerativeProduct, Generic

Product of differentiable exponential families, with log-partition function summed across replicates.

log_partition_function(params: Array) Array[source]

Sum of component log-partition functions at the given natural parameters.

class AnalyticProduct(rep_man: M, n_reps: int)[source]

Bases: DifferentiableProduct, Analytic, ABC, Generic

Product of analytic exponential families, with negative entropy summed across replicates.

initialize_from_sample(key: Array, sample: Array, location: float = 0.0, shape: float = 0.1) Array[source]

Initialize by delegating to each replicate’s initialize_from_sample.

This override ensures we use the Product version (which respects domain-specific initialization in each replicate) rather than the generic Analytic version.

negative_entropy(means: Array) Array[source]

Sum of component negative entropies at the given mean parameters.