ConditionalDirichlet#

class hybrid_aif.ConditionalDirichlet[source]#

Bases: _TabularConditional

Independent 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 (a Learnable), placed in SystemParams.likelihood / transition / initial_state_prior in place of a point table. Swapping forms changes the pytree structure; to stop learning without losing the counts, pass a rate of 0.0 to System.learn.

Design: docs/design/parameter-learning.md D3, D7; docs/design/structure-learning.md S3

concentration: Array#

Positive counts, (..., num_levels, *parent_shape), child axis first.

parent_ndims: int#

The number of parent axes (a count, not their sizes).

alpha0: Array | None = None#

The decay anchor a decay < 1 update relaxes toward: the declaration’s own concentration (from_table() anchor="prior"), a scalar (a uniform table, anchor="uniform"), or None, in which case decaying the slot raises.

growth: Array | None = None#

The growth propensity α, a scalar or None, 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 whatever growth says; growth is 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,
)[source]#

Concentration strength · table from a child-normalized probability table.

strength is the pseudo-count total per parent configuration (default 1.0). anchor is what a decay < 1 update relaxes toward: "prior" (or True) keeps the initial concentration as alpha0, a second table of parameters; "uniform" keeps a scalar 1.0, which costs nothing; an array is kept as given; False keeps none, and the slot then cannot decay. growth is 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.

mean()[source]#

Posterior-mean CPD table (normalized over the child axis).

point()[source]#

Posterior-mean CPD as a ConditionalCategorical (the slot’s point form, consumed by as_env and 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_obs is an integer index or a one-hot/probability vector over child levels; each parent belief is a Categorical or 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.0 is the pure-conjugate update α + lr·stats, bitwise. Any other decay needs alpha0; see dirichlet._absorbed for small anchors.

update(child_obs, parent_beliefs, lr=1.0)[source]#

Conjugate count update concentration + lr·(onehot(child_obs) ⊗ q(parents)).

stats() then absorb(), 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 concentration layout.

condition_on(parent_indices)[source]#

The child distribution at one parent configuration (unbatched indices).

__init__(concentration, parent_ndims, alpha0=None, growth=None)#