ConditionalCategorical#
- class hybrid_aif.ConditionalCategorical[source]#
Bases:
_TabularConditionalTabular CPD P(child | parents): one simplex per parent configuration.
log_tableholds unnormalized log-probabilities with structure block(num_levels, *parent_shape); methods normalize over the child axis, so the stored table carries a per-config additive gauge, asCategorical.logitsdoes.- log_table: Array#
Unnormalized log-probabilities,
(..., num_levels, *parent_shape), child axis first.
- classmethod from_parent_leading(log_table, parent_ndims)[source]#
Build from the parent-leading layout
(*parent_shape, num_levels).Moves the child axis to the front of the structure block; batch axes stay leading and only the trailing
parent_ndims + 1axes are re-laid-out. ForWof shape(num_actions=3, num_modes=2)withW[u, j] = log P(mode j | action u),from_parent_leading(W, 1)equalsConditionalCategorical(log_table=W.T, parent_ndims=1).
- expected_log(parent_beliefs)[source]#
E_q(parents)[log P(child | parents)] — the FPI contraction; (…, num_levels).
- average(parent_beliefs)[source]#
Bayesian model average Σ_parents P(child|parents) q(parents) as a Categorical.
- condition_on(parent_indices)[source]#
The child distribution at one parent configuration (unbatched indices).
- is_normalized(atol=1e-05)[source]#
Whether the stored table exponentiates to a simplex per parent config.
Methods renormalize regardless; this validates externally supplied tables. Returns a boolean array over batch axes.
- join(parent_marginal)[source]#
Chain-rule product P(child|parents)·P(parents) as a JointCategorical.
The joint’s event axes are
(num_levels, *parent_shape)— child axis first, parent axes in table order.parent_marginalis aCategorical(single parent) or aJointCategoricalwhose event shape equalsparent_shape.
- __init__(log_table, parent_ndims)#