JointCategorical#

class hybrid_aif.JointCategorical[source]#

Bases: Distribution

Joint distribution over event_ndims discrete axes.

Samples and log_prob arguments are stacked int32 indices with a trailing axis of length event_ndims, one index per event axis.

logits: Array#

Unnormalized log-probabilities over the trailing event_ndims axes jointly, (..., *event_shape) (a single additive gauge for the whole table).

event_ndims: int#

The number of trailing event axes.

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

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

property log_probs: Array#

Jointly normalized log-probability table, same shape as logits.

log_prob(x)[source]#

Log mass at stacked indices x (trailing axis of length event_ndims).

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

Stacked int32 indices, shape sample_shape + batch_shape + (event_ndims,).

mean()[source]#

Moment view: the joint probability table (one-hot expectation).

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.

to_conditional(child_axis)[source]#

P(child | rest): normalize along one event axis per configuration of the others.

child_axis indexes the event block (negatives allowed). The child axis moves to the front of the structure block and the other event axes become parent axes in order; normalization happens on read, so the conversion is a pure axis move.

marginalize(axes)[source]#

Sum OUT the given event axes (event-relative indices; negatives allowed).

Returns the joint over the remaining event axes, or a Categorical when exactly one remains.

__init__(logits, event_ndims)#