Dirichlet#

class hybrid_aif.Dirichlet[source]#

Bases: ExponentialFamily

A Dirichlet distribution over the num_levels simplex, batched over leading axes.

The learnable form of a categorical prior (a point Categorical’s conjugate): point() gives the expected categorical, stats() and absorb() are the count update, novelty() the novelty of the counts. Design: docs/design/parameter-learning.md D7; docs/design/structure-learning.md S3.

concentration: Array#

Positive counts, (..., num_levels).

alpha0: Array | None = None#

The decay anchor a decay < 1 update relaxes toward: the prior’s own concentration, a scalar (uniform), or None.

growth: Array | None = None#

The growth propensity α of a growable state factor, a scalar or None: the pseudo-count the prior gives a level not yet live. A level with zero concentration is absent from the family whatever growth says; growth is what lets such a level be woken, and without it the level stays absent.

property batch_shape: tuple[int, ...]#

Leading (batch) axes: leaf shape minus the family’s fixed trailing structure.

log_prob(x)[source]#

Log density/mass at x; broadcasts over batch axes.

sample(key, sample_shape=())[source]#

Draw samples with shape sample_shape + batch_shape + event_shape.

mean()[source]#

Mean (moment view).

mode()[source]#

Density mode; defined only when all concentrations exceed 1.

expected_log_params()[source]#

E[log p] per level (digamma differences), averaging over the parameters.

Unnormalized as a log-prior, so an FPI prior takes log(mean()) via point() instead.

point()[source]#

Posterior-mean probability vector as a Categorical (the slot’s point form).

stats(child_obs)[source]#

One tick’s sufficient statistic: onehot of an index, or a probability vector (e.g. q(s_0) for an initial-prior count update) passed through.

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 exact conjugate update, bitwise; any other decay needs alpha0 (see _absorbed).

novelty()[source]#

Parameter-info-gain weights over the levels (exact spm_wnorm, better-when-larger, zero counts masked).

entropy()[source]#

Differential/discrete entropy as an Interval (zero-width when exact).

kl_to(other)[source]#

KL(self ‖ other) for other of the same family, as an Interval.

natural()[source]#

Natural parameters as a tuple of arrays (gauge documented per class).

classmethod from_natural(eta)[source]#

Inverse of natural(), up to gauge and float error.

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