mixle.stats.sequences._keyed_accumulator module¶
Shared key-merge plumbing for the (init, trans) two-key Markov-transform accumulators.
Both MarkovTransformAccumulator (dense, 3-set) and SparseMarkovAssociationAccumulator
(sparse, 2-set) hold two independently keyed sufficient statistics – an init_count vector and a
trans_count (sparse) matrix – plus a delegated size/length accumulator. The single-key default
on StatisticAccumulator (keyed on self.keys) does not fit this two-key shape, so the pooling
logic below is shared here rather than re-implemented in each module.
The E-step itself (responsibility scatter, _track_ll log-density byproduct) is not shared: the
dense and sparse paths differ in row-weight construction (outer product vs broadcast), init-term
smoothing, normalization denominator, sparse-matrix type, and scatter mechanism, and the sparse model
carries an extra low-memory bincount encoding with no dense analogue. Only the genuinely identical
key plumbing is collapsed.
- class InitTransKeyedAccumulator[source]
Bases:
objectMixin providing
key_merge/key_replacefor an (init_key, trans_key) accumulator.Expects the host accumulator to define
init_key,trans_key,init_count,trans_count, andsize_accumulator.size_accumulatormay beNone(the dense model) or a real accumulator/NullAccumulator(the sparse model); theis not Noneguard handles both, sinceNullAccumulator.key_merge/key_replaceare no-ops.- key_merge(stats_dict)[source]
Merge the keyed
init_countandtrans_countintostats_dict, then the size acc.