mixle.stats.sets.integer_step_bernoulli_edit module¶
Integer step Bernoulli edit distributions over pairs of finite sets.
Data type: Tuple[Sequence[int], Sequence[int]]: An observation x = (x1, x2) is a pair of integer sets (prev set, next set), each a subset of S = {0,1,2,…N-1}.
The density has the same form as the integer Bernoulli edit set distribution (see mixle.stats.sets.integer_bernoulli_edit): each integer k independently transitions in or out of the set with probabilities p(k in x2 | k in x1), p(k in x2 | k not in x1), etc., and the previous set x1 follows an init distribution,
p(x1, x2) = P_init(x1) * prod_{k=0}^{N-1} p(k in/not-in x2 | k in/not-in x1).
The “step” variant differs only in estimation: after the per-element edit probabilities are computed, the estimator fits a two-level step function to the addition probabilities p(present | missing) and the removal probabilities p(missing | present), so that each element receives one of just two probability levels (a high level for the top-ranked elements and a low level for the rest), chosen to maximize the Bernoulli likelihood of the per-element estimates.
Every class here subclasses its non-step counterpart in mixle.stats.sets.integer_bernoulli_edit and
overrides only what genuinely differs: the estimator’s step-fit, the constructor signatures (the step
distribution/estimator do not carry the non-step keys plumbing), and the class-name strings used in
__str__ and in the types returned by the distribution’s factory methods.
- class IntegerStepBernoulliEditDistribution(log_edit_pmat, init_dist=None, name=None)[source]
Bases:
IntegerBernoulliEditDistributionStep Bernoulli edit set distribution: each integer independently transitions in/out between two sets.
Identical in form to
IntegerBernoulliEditDistribution; only the estimator (a two-level step fit) differs. The step distribution does not carry the non-stepkeysplumbing.- Parameters:
- sampler(seed=None)[source]
Create a sampler for this integer step Bernoulli edit distribution.
- Parameters:
seed (Optional[int]) – Used to set seed in random sampler.
- Returns:
Sampler bound to this distribution.
- Return type:
IntegerStepBernoulliEditSampler
- estimator(pseudo_count=None)[source]
Create an IntegerStepBernoulliEditEstimator with matching num_vals.
- Parameters:
pseudo_count (Optional[float]) – Used to re-weight sufficient statistics in estimation.
- Returns:
Estimator configured with matching support size.
- Return type:
IntegerStepBernoulliEditEstimator
- dist_to_encoder()[source]
Return a data encoder for integer step Bernoulli edit observations.
- Return type:
IntegerStepBernoulliEditDataEncoder
- enumerator()[source]
Returns IntegerStepBernoulliEditEnumerator iterating set-pairs in descending probability order.
- Return type:
IntegerStepBernoulliEditEnumerator
- class IntegerStepBernoulliEditEnumerator(dist)[source]
Bases:
IntegerBernoulliEditEnumeratorEnumerates finite previous/next integer-set pairs for the step edit-set distribution.
- Parameters:
dist (IntegerBernoulliEditDistribution)
- class IntegerStepBernoulliEditSampler(dist, seed=None)[source]
Bases:
IntegerBernoulliEditSamplerSampler for
(previous set, next set)pairs from a stepwise integer Bernoulli-edit distribution.Identical to
IntegerBernoulliEditSampler; only the bound distribution type differs.- Parameters:
dist (IntegerBernoulliEditDistribution)
seed (int | None)
- class IntegerStepBernoulliEditAccumulator(num_vals, init_acc=NullAccumulator(), keys=None)[source]
Bases:
IntegerBernoulliEditAccumulatorAccumulator for removed, added, and kept counts from stepwise integer set pairs.
Identical to
IntegerBernoulliEditAccumulator; only the encoder type returned byacc_to_encoder()differs.- Parameters:
- acc_to_encoder()[source]
Return a data encoder built from the previous-set accumulator.
- Return type:
IntegerStepBernoulliEditDataEncoder
- class IntegerStepBernoulliEditAccumulatorFactory(num_vals, init_factory=None, keys=None)[source]
Bases:
IntegerBernoulliEditAccumulatorFactoryFactory for integer step Bernoulli edit accumulators.
- make()[source]
Return a new integer step Bernoulli edit accumulator.
- Return type:
IntegerStepBernoulliEditAccumulator
- class IntegerStepBernoulliEditEstimator(num_vals=MISSING, init_estimator=NullEstimator(), min_prob=1.0e-128, pseudo_count=None, suff_stat=None, name=None, keys=None, num_values=MISSING)[source]
Bases:
IntegerBernoulliEditEstimatorEstimate integer step Bernoulli edit distributions with a two-level edit-probability fit.
- Parameters:
- accumulator_factory()[source]
Return an accumulator factory configured from this estimator.
- Return type:
IntegerStepBernoulliEditAccumulatorFactory
- estimate(nobs, suff_stat)[source]
Estimate an IntegerStepBernoulliEditDistribution from aggregated sufficient statistics.
Per-element edit probabilities are estimated as in the non-step edit estimator, then the addition and removal probabilities are each replaced by a two-level step-function fit.
- class IntegerStepBernoulliEditDataEncoder(init_encoder)[source]
Bases:
IntegerBernoulliEditDataEncoderEncode iid
(previous set, next set)observations for vectorized scoring.Identical to
IntegerBernoulliEditDataEncoder; only the reported class name differs.- Parameters:
init_encoder (DataSequenceEncoder)