mixle.stats.univariate.discrete.point_mass module

Fixed point-mass distribution.

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]
classmethod compute_declaration()[source]
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]

Draw observations.

Combinator samplers (mixture/sequence/…) accept batched. With batched=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 independent RandomState, batching consumes each stream in the same order as the loop, so the draws are identical to the legacy path. batched=False forces that legacy per-draw loop as a guaranteed- stable reference. Leaf samplers are already vectorized and ignore the flag.

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]
Parameters:
  • x (Any)

  • weight (float)

  • estimate (PointMassDistribution | None)

Return type:

None

seq_update(x, weights, estimate)[source]
Parameters:
  • x (ndarray)

  • weights (ndarray)

  • estimate (PointMassDistribution | None)

Return type:

None

seq_update_engine(x, weights, estimate, engine)[source]
Parameters:
  • x (ndarray)

  • weights (Any)

  • estimate (PointMassDistribution | None)

  • engine (Any)

Return type:

None

initialize(x, weight, rng)[source]
Parameters:
Return type:

None

seq_initialize(x, weights, rng)[source]
Parameters:
Return type:

None

combine(suff_stat)[source]
Parameters:

suff_stat (Any)

Return type:

PointMassAccumulator

value()[source]
Return type:

None

from_value(x)[source]
Parameters:

x (Any)

Return type:

PointMassAccumulator

key_merge(stats_dict)[source]

Pool this accumulator’s statistics into stats_dict under its merge key.

The structural default implements the common single-key pattern: store the accumulator under self.keys the first time the key is seen, else combine into 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. A keys of None (the default) is a no-op.

Parameters:

stats_dict (dict[str, Any])

Return type:

None

key_replace(stats_dict)[source]

Replace this accumulator’s statistics from the pooled stats_dict entry (see key_merge).

Parameters:

stats_dict (dict[str, Any])

Return type:

None

acc_to_encoder()[source]
Return type:

PointMassDataEncoder

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

Bases: StatisticAccumulatorFactory

Factory for PointMassAccumulator.

Parameters:
  • value (Any)

  • keys (str | None)

make()[source]
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 type:

PointMassAccumulatorFactory

estimate(nobs, suff_stat=None)[source]
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 the iid observation sequence x for vectorized evaluation.

Parameters:

x (Sequence[Any])

Return type:

ndarray