Skip to content

Variable

Variable describes a finite discrete probabilistic variable, optionally owned by a graph node.

See Belief Propagation for domain, state, prior, evidence, and posterior behavior.

Reference

tonggraph.Variable

Finite discrete probabilistic variable attached to an optional graph node.

id property

id: int

Internal integer variable ID.

owner_id property

owner_id: int | None

Owning graph node ID, if the variable is attached to a node.

domain property

domain: str

Variable domain, commonly "binary" or "categorical".

states property

states: list[str]

Ordered state labels used by priors, CPDs, factors, and posteriors.

prior property

prior: dict[str, PropertyValue]

Prior distribution metadata.

posterior property

posterior: dict[str, PropertyValue]

Persisted posterior metadata stored with the variable record.