mbdlyb.formalisms.base

Base classes for formalism-specific node types in MBD models.

Provides CPTEnabledNode and related functionality for formalisms that use Conditional Probability Tables (CPT) for representing dependencies.

Classes

CPTEnabledNode

Node that supports Conditional Probability Table (CPT) representation.

Module Contents

class mbdlyb.formalisms.base.CPTEnabledNode[T](name: str, states: list[T], net: MBDNet)

Bases: mbdlyb.MBDNode[T]

Node that supports Conditional Probability Table (CPT) representation.

CPTEnabledNode extends MBDNode to support representation via CPTs, which explicitly enumerate probabilities for all combinations of parent states. This is used in Bayesian networks and similar formalisms.

Variables:
  • _PARENT_RELATION_TYPE (Type[MBDDependency]) – The dependency type to consider as parents.

  • _param_value_mapping_fn (dict[Type[MBDNode], Callable]) – Functions to map state values for parameters.

  • _cpt_parents (Optional[list[MBDNode]]) – Override for the parent nodes used in CPT.

  • cpt (Optional[np.ndarray]) – The cached conditional probability table array.

cpt: numpy.ndarray | None = None
property cpt_parents: list[mbdlyb.MBDNode]

Get the parent nodes used for CPT computation.

Returns either the explicitly set parents or the source nodes of parent relations matching the parent relation type.

Returns:

List of parent nodes.

Return type:

list[MBDNode]

property has_cpt: bool

Check if this node has a CPT defined.

Returns:

True if the cpt array is not None.

Return type:

bool