mixle.stats.univariate.discrete.point_mass module

Fixed point-mass distribution and estimator support.

This module implements a sequence-encodable Dirac distribution, including sampling, encoding, enumeration, backend scoring, and the estimator hooks needed for mixture and combinator use.

class PointMassDistribution(value, name=None, keys=None)[source]

Bases: SequenceEncodableProbabilityDistribution

Fixed Dirac/point-mass distribution assigning all mass to one value.

Parameters:
  • value (Any)

  • name (str | None)

  • keys (str | None)

classmethod compute_capabilities()[source]

Declare generic NumPy/Torch scoring support for fixed atoms.

classmethod compute_declaration()[source]

Return the declaration for a fixed non-estimated atom.

density(x)[source]

Return the probability density or mass at a single observation.

Parameters:

x (Any)

Return type:

float

log_density(x)[source]

Return the log-density or log-mass at a single observation.

Parameters:

x (Any)

Return type:

float

seq_log_density(x)[source]

Return vectorized log-density values for sequence-encoded observations.

Parameters:

x (ndarray)

Return type:

ndarray

backend_seq_log_density(x, engine)[source]

Engine-neutral vectorized log-density from encoded equality flags.

Parameters:
Return type:

Any

classmethod backend_stacked_params(dists, engine)[source]

Return stacked point-mass parameters for identical fixed atoms.

Parameters:
Return type:

dict[str, Any]

classmethod backend_stacked_log_density(x, params, engine)[source]

Return an (n, k) matrix of point-mass log densities.

Parameters:
Return type:

Any

classmethod backend_stacked_sufficient_statistics(x, weights, params, engine)[source]

Return per-component empty statistics for fixed point masses.

Parameters:
Return type:

tuple[None, …]

support_size()[source]

A single atom.

Return type:

int

sampler(seed=None)[source]

Return a sampler for drawing observations from this distribution.

Parameters:

seed (int | None)

Return type:

PointMassSampler

estimator(pseudo_count=None)[source]

Return an estimator for fitting this distribution from data.

Parameters:

pseudo_count (float | None)

Return type:

PointMassEstimator

dist_to_encoder()[source]

Return the data encoder used by this distribution for vectorized methods.

Return type:

PointMassDataEncoder

enumerator()[source]

Return an enumerator over the distribution support when available.

Return type:

PointMassEnumerator

quantized_index(max_bits, bin_width_bits=1.0)[source]

Return a bounded quantized support index for this observation.

Parameters:
Return type:

QuantizedEnumerationIndex

class PointMassEnumerator(dist)[source]

Bases: DistributionEnumerator

Enumerate the single atom of a PointMassDistribution.

Parameters:

dist (PointMassDistribution)

class PointMassSampler(dist, seed=None)[source]

Bases: DistributionSampler

Sampler returning the fixed atom.

Parameters:
  • dist (PointMassDistribution)

  • seed (int | None)

sample(size=None)[source]

Return the fixed atom once or repeated size times.

Parameters:

size (int | None)

Return type:

Any | Sequence[Any]

class PointMassAccumulator(value, keys=None)[source]

Bases: SequenceEncodableStatisticAccumulator

Accumulator for a fixed point mass; no parameters are learned.

Parameters:
  • value (Any)

  • keys (str | None)

update(x, weight, estimate)[source]

Ignore one observation because the atom is fixed.

Parameters:
  • x (Any)

  • weight (float)

  • estimate (PointMassDistribution | None)

Return type:

None

seq_update(x, weights, estimate)[source]

Ignore encoded observations because the atom is fixed.

Parameters:
  • x (ndarray)

  • weights (ndarray)

  • estimate (PointMassDistribution | None)

Return type:

None

seq_update_engine(x, weights, estimate, engine)[source]

Ignore engine-resident observations because the atom is fixed.

Parameters:
  • x (ndarray)

  • weights (Any)

  • estimate (PointMassDistribution | None)

  • engine (Any)

Return type:

None

initialize(x, weight, rng)[source]

Ignore initialization observations because the atom is fixed.

Parameters:
Return type:

None

seq_initialize(x, weights, rng)[source]

Ignore encoded initialization observations because the atom is fixed.

Parameters:
Return type:

None

combine(suff_stat)[source]

Return this accumulator because fixed atoms have no sufficient statistics.

Parameters:

suff_stat (Any)

Return type:

PointMassAccumulator

value()[source]

Return None because fixed atoms have no sufficient statistics.

Return type:

None

from_value(x)[source]

Return this accumulator because there is no state to restore.

Parameters:

x (Any)

Return type:

PointMassAccumulator

key_merge(stats_dict)[source]

Register the key with empty statistics when configured.

Parameters:

stats_dict (dict[str, Any])

Return type:

None

key_replace(stats_dict)[source]

Ignore keyed replacements because there is no accumulator state.

Parameters:

stats_dict (dict[str, Any])

Return type:

None

acc_to_encoder()[source]

Return the equality-mask encoder for this atom.

Return type:

PointMassDataEncoder

class PointMassAccumulatorFactory(value, keys=None)[source]

Bases: StatisticAccumulatorFactory

Factory for PointMassAccumulator.

Parameters:
  • value (Any)

  • keys (str | None)

make()[source]

Create an empty point-mass accumulator.

Return type:

PointMassAccumulator

class PointMassEstimator(value, pseudo_count=None, suff_stat=None, name=None, keys=None)[source]

Bases: ParameterEstimator

Estimator that always returns the configured point mass.

Parameters:
  • value (Any)

  • pseudo_count (float | None)

  • suff_stat (Any | None)

  • name (str | None)

  • keys (str | None)

accumulator_factory()[source]

Return a factory for point-mass no-op accumulators.

Return type:

PointMassAccumulatorFactory

estimate(nobs, suff_stat=None)[source]

Return the configured point mass unchanged.

Parameters:
  • nobs (float | None)

  • suff_stat (Any | None)

Return type:

PointMassDistribution

class PointMassDataEncoder(value)[source]

Bases: DataSequenceEncoder

Encode observations as a boolean equality mask against the fixed atom.

Parameters:

value (Any)

seq_encode(x)[source]

Encode observations as booleans indicating equality with the fixed atom.

Parameters:

x (Sequence[Any])

Return type:

ndarray