mixle.stats.combinator.ignored module¶
Create, estimate, and sample from an IgnoredDistribution.
Defines the IgnoredDistribution, IgnoredSampler, IgnoredAccumulatorFactory, IgnoredAccumulator, IgnoredEstimator, and the IgnoredDataEncoder classes for use with mixle.
Ignored distribution is simply a distribution that is ignored in estimation and treated as fixed.
- class IgnoredDistribution(dist, name=None)[source]
Bases:
SequenceEncodableProbabilityDistributionDistribution wrapper that assigns zero log-density while preserving an estimator interface.
- Parameters:
dist (SequenceEncodableProbabilityDistribution | None)
name (str | None)
- compute_capabilities()[source]
- compute_declaration()[source]
- get_prior()[source]
Delegate to the wrapped distribution’s
get_prior(Ignored owns no prior).- Return type:
- set_prior(prior)[source]
Delegate to the wrapped distribution’s
set_prior;Nonekeeps existing behavior.- Parameters:
prior (Any)
- Return type:
None
- expected_log_density(x)[source]
Delegate prior-expected log-density to the wrapped distribution.
- Parameters:
x (T)
- Return type:
- seq_expected_log_density(x)[source]
Delegate vectorized prior-expected log-density to the wrapped distribution.
- Parameters:
x (E)
- Return type:
- density(x)[source]
Evaluate the density of the IgnoredDistribution at x.
- Parameters:
x (T) – Type corresponding to attribute ‘dist’.
- Returns:
Density of attribute ‘dist’ at x
- Return type:
- log_density(x)[source]
Evaluate the log-density of the IgnoredDistribution at x.
- Parameters:
x (T) – Type corresponding to attribute ‘dist’.
- Returns:
log-density of attribute ‘dist’ at x.
- seq_log_density(x)[source]
Return vectorized log-density values for sequence-encoded observations.
- Parameters:
x (E)
- Return type:
- backend_seq_log_density(x, engine)[source]
Engine-neutral vectorized log-density delegated to the wrapped distribution.
- classmethod backend_stacked_params(dists, engine)[source]
Return stacked child parameters for homogeneous ignored-wrapper mixtures.
- classmethod backend_stacked_log_density(x, params, engine)[source]
Return an
(n, k)matrix of delegated child log densities.
- classmethod backend_stacked_sufficient_statistics(x, weights, params, engine)[source]
Return empty legacy statistics for each ignored component.
- sampler(seed=None)[source]
Return a sampler for drawing observations from this distribution.
- Parameters:
seed (int | None)
- Return type:
IgnoredSampler
- estimator(pseudo_count=None)[source]
Return an estimator for fitting this distribution from data.
- Parameters:
pseudo_count (float | None)
- Return type:
IgnoredEstimator
- dist_to_encoder()[source]
Return the data encoder used by this distribution for vectorized methods.
- Return type:
IgnoredDataEncoder
- class IgnoredSampler(dist, seed=None)[source]
Bases:
DistributionSampler- Parameters:
dist (IgnoredDistribution)
seed (int | None)
- sample(size=None)[source]
Draw observations.
Combinator samplers (mixture/sequence/…) accept
batched. Withbatched=True(the default) each child stream is drawn in one vectorized call instead of a per-draw Python loop – far faster. Because every child sampler owns an independentRandomState, batching consumes each stream in the same order as the loop, so the draws are identical to the legacy path.batched=Falseforces that legacy per-draw loop as a guaranteed- stable reference. Leaf samplers are already vectorized and ignore the flag.- Parameters:
size (int | None)
- class IgnoredAccumulator(encoder=NullDataEncoder(), name=None)[source]
Bases:
SequenceEncodableStatisticAccumulator- Parameters:
encoder (DataSequenceEncoder | None)
name (str | None)
- update(x, weight, estimate)[source]
- Parameters:
x (T)
weight (float)
estimate (IgnoredDistribution | None)
- Return type:
None
- seq_update(x, weights, estimate)[source]
- Parameters:
x (E)
weights (ndarray)
estimate (IgnoredDistribution | None)
- Return type:
None
- seq_update_engine(x, weights, estimate, engine)[source]
- Return type:
None
- initialize(x, weight, rng)[source]
- Parameters:
x (T)
weight (float)
rng (RandomState | None)
- Return type:
None
- seq_initialize(x, weight, rng)[source]
- Parameters:
x (E)
weight (ndarray)
rng (RandomState | None)
- Return type:
None
- value()[source]
- Return type:
None
- key_merge(stats_dict)[source]
Pool this accumulator’s statistics into
stats_dictunder its merge key.The structural default implements the common single-key pattern: store the accumulator under
self.keysthe first time the key is seen, elsecombineinto the one already there. Accumulators with several named keys (e.g. an HMM’s init/trans/state keys) or a non-accumulator stats payload override this. AkeysofNone(the default) is a no-op.
- key_replace(stats_dict)[source]
Replace this accumulator’s statistics from the pooled
stats_dictentry (see key_merge).
- acc_to_encoder()[source]
- Return type:
IgnoredDataEncoder
- class IgnoredAccumulatorFactory(encoder=NullDataEncoder(), name=None)[source]
Bases:
StatisticAccumulatorFactory- Parameters:
encoder (DataSequenceEncoder | None)
name (str | None)
- make()[source]
- Return type:
IgnoredAccumulator
- class IgnoredEstimator(dist=NullDistribution(), pseudo_count=None, suff_stat=None, keys=None, name=None)[source]
Bases:
ParameterEstimator- Parameters:
- accumulator_factory()[source]
- get_prior()[source]
Delegate to the wrapped distribution’s
get_prior(Ignored estimates nothing of its own).- Return type: