mixle.stats.combinator.null_dist module¶
Create, estimate, and sample from a null distribution.
Defines the NullDistribution, NullSampler, NullAccumulatorFactory, NullAccumulator, NullEstimator, and the NullDataEncoder classes for use with mixle.
The NullDistribution object and its related classes are space filling objects meant for consistency in type hints.
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]
- classmethod compute_declaration()[source]
- 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 NullSampler object.
- Parameters:
seed (Optional[int]) – Seed for random number generator (unused).
- Returns:
NullSampler object.
- Return type:
NullSampler
- estimator(pseudo_count=None)[source]
Create a NullEstimator object.
- Parameters:
pseudo_count (Optional[float]) – Kept for interface consistency (has no effect on estimation).
- Returns:
NullEstimator object.
- Return type:
NullEstimator
- dist_to_encoder()[source]
Returns a NullDataEncoder object for encoding sequences of data.
- Return type:
NullDataEncoder
- enumerator()[source]
Returns a NullEnumerator object enumerating the support of the NullDistribution.
- 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]
- 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]
Returns a NullDataEncoder object for encoding sequences of data.
- Return type:
NullDataEncoder
- class NullAccumulatorFactory(keys=None)[source]
Bases:
StatisticAccumulatorFactoryFactory for creating NullAccumulator objects.
- Parameters:
keys (str | None)
- make()[source]
Returns a new NullAccumulator object.
- 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]
Returns a NullAccumulatorFactory for creating NullAccumulator objects.
- Return type:
NullAccumulatorFactory
- class NullDataEncoder[source]
Bases:
DataSequenceEncoderData encoder for the NullDistribution. Encodes any sequence as its length.