mixle.stats.parameter_packing module

Primary-parameter packing for extrapolation-based EM acceleration (SQUAREM).

This lives in the stats layer on purpose: the (extract, rebuild) handlers must name concrete distribution families, which orchestration-level modules (mixle.inference.em – see its module docstring and compute_metadata_test’s guard) are architecturally barred from doing. The consumer is mixle.inference.em.SquaremEM, which imports only the packer FUNCTION.

squarem_packer(model)[source]

Build (pack, unpack) for SquaremEM over model’s primary parameters.

Supported out of the box: recursively nested MixtureDistribution and CompositeDistribution nodes with Gaussian / Laplace / Exponential / Poisson / Categorical leaves and no priors attached (a MAP fit changes the fixed point). Anything else raises NotImplementedError with the escape hatch named: pass an explicit packer=(pack, unpack) to SquaremEM for custom models.

pack(model) -> theta and unpack(theta) -> model round-trip losslessly (asserted in tests); mixture weights travel as log-weights re-normalized on unpack.

Parameters:

model (Any)

Return type:

tuple[Callable[[Any], ndarray], Callable[[ndarray], Any]]