Combinators¶
Combinators for composing exponential families: location-shape products and replicated (independent) products.
Class Hierarchy¶
Location-Shape Models¶
- class LocationShape[source]¶
Bases:
Pair,ExponentialFamily,ABC,GenericA 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.
- sufficient_statistic(x: Array) Array[source]¶
Compute the sufficient statistic \(\mathbf{s}(x)\) of an observation.
Product Models¶
- class Product(rep_man: M, n_reps: int)[source]¶
Bases:
Replicated,ExponentialFamily,GenericProduct of
n_repsindependent 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.- 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.
- 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.
Analyticoverrides this to use average sufficient statistics.
- class GenerativeProduct(rep_man: M, n_reps: int)[source]¶
Bases:
Product,Generative,GenericProduct of generative exponential families, adding independent sampling across replicates.
- class DifferentiableProduct(rep_man: M, n_reps: int)[source]¶
Bases:
Differentiable,GenerativeProduct,GenericProduct of differentiable exponential families, with log-partition function summed across replicates.
- class AnalyticProduct(rep_man: M, n_reps: int)[source]¶
Bases:
DifferentiableProduct,Analytic,ABC,GenericProduct 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.