mixle.stats.multivariate.composition moduleΒΆ
Compositional transforms and a Jacobian-correct logratio-normal density.
Compositions are strictly positive vectors on the unit simplex. clr and
ilr map positive rays to logratio coordinates; AitchisonNormalDistribution
uses an ilr Gaussian and reports density with respect to ordinary Lebesgue
measure on the first D-1 simplex coordinates. Consequently its score
includes the absolute ilr change-of-variables Jacobian
|d ilr(x) / d(x_1,...,x_{D-1})| = 1 / (sqrt(D) * product_i x_i).
- closure(x, total=1.0)[source]
Normalize strictly positive finite rows to a positive finite total.
- clr(x)[source]
Return centered logratios for strictly positive finite compositions.
- clr_inv(y)[source]
Map finite clr-coordinate rows to the unit simplex.
- ilr(x, basis=None)[source]
Map strictly positive
D-part rows toD-1ilr coordinates.
- ilr_inv(y, basis=None)[source]
Map finite
D-1ilr rows to strictly positive unit compositions.
- ilr_basis(d)[source]
Return the Helmert
(D, D-1)orthonormal contrast basis.
- class AitchisonNormalDistribution(mean, cov, name=None, keys=None)[source]
Bases:
SequenceEncodableProbabilityDistributionLogratio-normal density on ordinary unit-simplex coordinates.
- property mean: ndarray
Return the Gaussian mean in ilr coordinates.
- property cov: ndarray
Return the Gaussian covariance in ilr coordinates.
- density(x)[source]
Return ordinary-coordinate simplex density.
- log_density(x)[source]
Return density relative to the first
D-1simplex coordinates.
- seq_log_density(x)[source]
Score an encoded
(ilr coordinates, log Jacobian)payload.
- sampler(seed=None)[source]
Return a push-forward sampler from the ilr Gaussian.
- Parameters:
seed (int | None)
- Return type:
AitchisonNormalSampler
- estimator(pseudo_count=None)[source]
Return an estimator preserving keys and optional current-model smoothing.
- Parameters:
pseudo_count (float | None)
- Return type:
AitchisonNormalEstimator
- dist_to_encoder()[source]
Return a fixed-width composition encoder.
- Return type:
AitchisonNormalDataEncoder
- class AitchisonNormalSampler(dist, seed=None)[source]
Bases:
DistributionSamplerSample compositions by inverting Gaussian ilr draws.
- Parameters:
dist (AitchisonNormalDistribution)
seed (int | None)
- class AitchisonNormalDataEncoder(gaussian_encoder, n_parts)[source]
Bases:
DataSequenceEncoderEncode simplex rows as ilr coordinates plus their log Jacobians.
- Parameters:
gaussian_encoder (DataSequenceEncoder)
n_parts (int)
- seq_encode(x)[source]
Validate unit-simplex rows and encode coordinates with Jacobians.
- class AitchisonNormalEstimator(dim=None, pseudo_count=None, suff_stat=(None, None), name=None, keys=None)[source]
Bases:
ParameterEstimatorFit a Gaussian in ilr coordinates with explicit smoothing and keys.
- Parameters:
- accumulator_factory()[source]
Return a keyed accumulator factory delegated to the Gaussian estimator.
- Return type:
StatisticAccumulatorFactory
- class AitchisonNormalAccumulator(gaussian_acc, n_parts, keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorDelegate ilr-coordinate moments while preserving wrapper key semantics.
- update(x, weight, estimate)[source]
Update delegated Gaussian statistics from one raw composition.
- initialize(x, weight, rng)[source]
Initialize delegated statistics from one raw composition.
- seq_update(x, weights, estimate)[source]
Update delegated moments from encoded ilr coordinates.
- seq_initialize(x, weights, rng)[source]
Initialize delegated moments from encoded ilr coordinates.
- combine(suff_stat)[source]
Merge delegated Gaussian sufficient statistics.
- Parameters:
suff_stat (Any)
- Return type:
AitchisonNormalAccumulator
- from_value(x)[source]
Restore delegated Gaussian sufficient statistics.
- Parameters:
x (Any)
- Return type:
AitchisonNormalAccumulator
- acc_to_encoder()[source]
Return an encoder compatible with accumulated ilr dimension.
- Return type:
AitchisonNormalDataEncoder