ConditionalDirichlet#
- class hybrid_aif.ConditionalDirichlet[source]#
Bases:
_TabularConditionalIndependent Dirichlet priors over a CPD, one per parent configuration.
Same child-first layout as
ConditionalCategorical: a table of per-config Dirichlets on the child simplex, not a joint Dirichlet on the product simplex. As a declaration it is the learnable form of a tabular CPD slot (aLearnable), placed inSystemParams.likelihood/transition/initial_state_priorin place of a point table. Swapping forms changes the pytree structure; to stop learning without losing the counts, pass a rate of0.0toSystem.learn.Design: docs/design/parameter-learning.md D3, D7; docs/design/structure-learning.md S3
- alpha0: Array | None = None#
The decay anchor a
decay < 1update relaxes toward: the declaration’s own concentration (from_table()anchor="prior"), a scalar (a uniform table,anchor="uniform"), orNone, in which case decaying the slot raises.
- growth: Array | None = None#
The growth propensity
α, a scalar orNone, of a growable state factor whose weights this table holds (the transition column of a memoryless state factor; structure-learning.md S3): the pseudo-count the prior gives a level not yet live. A level whose concentration is zero is absent from the family whatevergrowthsays;growthis what lets such a level be woken, and without it the level stays absent.
- classmethod from_table(
- table,
- parent_ndims,
- strength=1.0,
- anchor=False,
- growth=None,
Concentration
strength · tablefrom a child-normalized probability table.strengthis the pseudo-count total per parent configuration (default1.0).anchoris what adecay < 1update relaxes toward:"prior"(orTrue) keeps the initial concentration asalpha0, a second table of parameters;"uniform"keeps a scalar1.0, which costs nothing; an array is kept as given;Falsekeeps none, and the slot then cannot decay.growthis the growth propensity of a growable state factor’s weights (a table with zero rows for its dead levels).
- expected_log_params()[source]#
E[log p] per level and parent config (digamma table) — what FPI consumes when averaging over likelihood parameters; same layout as
concentration.
- point()[source]#
Posterior-mean CPD as a
ConditionalCategorical(the slot’s point form, consumed byas_envand every probability-kind term).
- expected_entropy()[source]#
Expected child entropy under the parameters, per parent config.
ψ(α₀+1) − Σ_k (α_k/α₀)·ψ(α_k+1)withα₀the config’s total: the irreducible part of ambiguity. A diagnostic; the term tree does not consume it.Design: docs/design/parameter-learning.md D2
- stats(child_obs, parent_beliefs)[source]#
One tick’s count statistic
onehot(child_obs) ⊗ q(parent_1) ⊗ ....child_obsis an integer index or a one-hot/probability vector over child levels; each parent belief is aCategoricalor a raw probability vector.
- absorb(stats, lr=1.0, decay=1.0)[source]#
Absorb one tick’s statistic:
decay·α + (1−decay)·anchor + lr·stats.A static
decay == 1.0is the pure-conjugate updateα + lr·stats, bitwise. Any other decay needsalpha0; seedirichlet._absorbedfor small anchors.
- update(child_obs, parent_beliefs, lr=1.0)[source]#
Conjugate count update
concentration + lr·(onehot(child_obs) ⊗ q(parents)).stats()thenabsorb(), with no decay.
- novelty()[source]#
Parameter-info-gain weights over the child axis, per parent config (exact
spm_wnorm, better-when-larger, zero counts masked).
- sample(key)[source]#
Draw a CPD table from the posterior: one independent Dirichlet draw per parent configuration, returned in the child-first
concentrationlayout.
- condition_on(parent_indices)[source]#
The child distribution at one parent configuration (unbatched indices).
- __init__(concentration, parent_ndims, alpha0=None, growth=None)#