mixle.stats.combinator.null_dist module¶
Neutral null distribution used for optional structural slots.
The null distribution and its related classes fill optional model slots while preserving the standard distribution, sampler, accumulator, estimator, and encoder interfaces.
Notes
The density evaluates to 1.0 for any value (Any data type). The sampler generates None for any size input. Sequence encodings return None for any input.
- class NullDistribution(name=None)[source]
Bases:
SequenceEncodableProbabilityDistributionPlace-holder distribution assigning density 1.0 (log-density 0.0) to any observation (Any data type).
- Parameters:
name (str | None)
- classmethod compute_capabilities()[source]
Declare backend support for the zero-cost null distribution.
- classmethod compute_declaration()[source]
Return the generated-compute declaration for the null distribution.
- density(x)[source]
Density of NullDistribution. Always 1.0.
- Parameters:
x (Optional[Any]) – Observation of any type (ignored).
- Returns:
1.0 for any input.
- Return type:
- log_density(x)[source]
Log-density of NullDistribution. Always 0.0.
- Parameters:
x (Optional[Any]) – Observation of any type (ignored).
- Returns:
0.0 for any input.
- Return type:
- seq_log_density(x)[source]
Vectorized log-density evaluated at sequence encoded input x. Always 0.0.
- Parameters:
x (Optional[Any]) – Sequence encoded data; NullDataEncoder returns the sequence length.
- Returns:
A zero vector with one entry per encoded observation.
- Return type:
- backend_seq_log_density(x, engine)[source]
Engine-neutral vectorized log-density: zero for every encoded row.
- classmethod backend_stacked_params(dists, engine)[source]
Return stacked parameters for homogeneous null mixtures.
- classmethod backend_stacked_log_density(x, params, engine)[source]
Return an
(n, k)zero matrix for null-component log densities.
- classmethod backend_stacked_sufficient_statistics(x, weights, params, engine)[source]
Return empty legacy statistics for each null component.
- sampler(seed=None)[source]
Create a sampler for the null distribution.
- Parameters:
seed (Optional[int]) – Seed for random number generator (unused).
- Returns:
NullSampler that always samples
None.- Return type:
NullSampler
- estimator(pseudo_count=None)[source]
Create an estimator for the null distribution.
- Parameters:
pseudo_count (Optional[float]) – Kept for interface consistency (has no effect on estimation).
- Returns:
NullEstimator configured with this distribution’s name.
- Return type:
NullEstimator
- dist_to_encoder()[source]
Return the encoder used for null-distribution observations.
- Return type:
NullDataEncoder
- enumerator()[source]
Return an enumerator for the singleton null support.
- Return type:
NullEnumerator
- quantized_index(max_bits, bin_width_bits=1.0)[source]
Build the single-item bounded bit-quantized index for NullDistribution.
- class NullEnumerator(dist)[source]
Bases:
DistributionEnumeratorYields the single value None with probability one, matching NullSampler.sample().
- Parameters:
dist (NullDistribution)
- class NullSampler(dist, seed=None)[source]
Bases:
DistributionSamplerSampler for the NullDistribution. Always returns None.
- Parameters:
dist (NullDistribution)
seed (int | None)
- class NullAccumulator(keys=None)[source]
Bases:
SequenceEncodableStatisticAccumulatorAccumulator for NullDistribution. Accumulates no sufficient statistics.
- Parameters:
keys (str | None)
- update(x, weight, estimate)[source]
No-op update. Nothing is accumulated for the NullDistribution.
- Parameters:
x (Optional[Any]) – Observation of any type (ignored).
weight (float) – Weight for observation (ignored).
estimate (Optional[NullDistribution]) – Previous estimate (ignored).
- Return type:
None
- seq_update(x, weights, estimate)[source]
No-op vectorized update. Nothing is accumulated for the NullDistribution.
- Parameters:
x (Optional[Any]) – Sequence encoded data (ignored).
weights (np.ndarray) – Weights for observations (ignored).
estimate (Optional[NullDistribution]) – Previous estimate (ignored).
- Return type:
None
- seq_update_engine(x, weights, estimate, engine)[source]
Engine-neutral no-op accumulation for null statistics.
- Return type:
None
- initialize(x, weight, rng)[source]
No-op initialization for a single observation.
- Parameters:
x (Optional[Any]) – Observation of any type (ignored).
weight (float) – Weight for observation (ignored).
rng (Optional[np.random.RandomState]) – Random number generator (unused).
- Return type:
None
- seq_initialize(x, weights, rng)[source]
No-op vectorized initialization.
- Parameters:
x (Optional[Any]) – Sequence encoded data (ignored).
weights (np.ndarray) – Weights for observations (ignored).
rng (np.random.RandomState) – Random number generator (unused).
- Return type:
None
- combine(suff_stat)[source]
Combine sufficient statistics (no-op).
- Parameters:
suff_stat (Optional[Any]) – Sufficient statistics (ignored).
- Returns:
Self, unchanged.
- Return type:
NullAccumulator
- value()[source]
Returns None (the NullAccumulator has no sufficient statistics).
- Return type:
None
- from_value(x)[source]
Set accumulator from sufficient statistics (no-op).
- Parameters:
x (Optional[Any]) – Sufficient statistics (ignored).
- Returns:
Self, unchanged.
- Return type:
NullAccumulator
- key_merge(stats_dict)[source]
Register the key in stats_dict (the NullAccumulator stores no sufficient statistics).
- Parameters:
stats_dict (Dict[str, Any]) – Dict mapping keys to shared sufficient statistics.
- Returns:
None.
- Return type:
None
- key_replace(stats_dict)[source]
No-op kept for interface consistency (the NullAccumulator stores no sufficient statistics).
- Parameters:
stats_dict (Dict[str, Any]) – Dict mapping keys to shared sufficient statistics (ignored).
- Returns:
None.
- Return type:
None
- acc_to_encoder()[source]
Return the encoder associated with this accumulator.
- Return type:
NullDataEncoder
- class NullAccumulatorFactory(keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for null accumulators.
- Parameters:
keys (str | None)
- make()[source]
Return a fresh null accumulator.
- Return type:
NullAccumulator
- class NullEstimator(pseudo_count=None, suff_stat=None, name=None, keys=None)[source]
Bases:
ParameterEstimatorEstimator that always produces a NullDistribution regardless of the data.
- accumulator_factory()[source]
Return a factory for null accumulators.
- Return type:
NullAccumulatorFactory
- estimate(nobs, suff_stat=None)[source]
Returns a NullDistribution; arguments are ignored.
- Parameters:
nobs (Optional[float]) – Number of observations (ignored).
suff_stat (Optional[Any]) – Sufficient statistics (ignored).
- Returns:
NullDistribution carrying this estimator’s name.
- Return type:
NullDistribution
- class NullDataEncoder[source]
Bases:
DataSequenceEncoderData encoder for the NullDistribution. Encodes any sequence as its length.