VariableElimination.addJointTarget

VariableElimination.addJointTarget(targets)

Add a set of nodes as a new joint target.

The joint posterior of these nodes, and of any subset of them, is then given by jointPosterior. A set included in an existing joint target is not added (its posterior is computed from that joint target), and a set including existing joint targets replaces them. The marginal targets are not changed.

Parameters:

targets (set[int | str]) – the ids or the names of the nodes

Raises:
Return type:

None

Example

import pyagrum as gum

bn = gum.fastBN("A->B->C")
bn.cpt("A").fillWith([0.2, 0.8])
bn.cpt("B").fillWith([0.9, 0.1, 0.3, 0.7])
bn.cpt("C").fillWith([0.6, 0.4, 0.1, 0.9])
ie = gum.VariableElimination(bn)
ie.addJointTarget({"A", "C"})
ie.jointTargets()
# [{0, 2}]
print(ie.jointPosterior({"A", "C"}).reorganize(["A", "C"]))  # fixed order of the variables
#
#       ║  A                │
# C     ║0        │1        │
# ──────║─────────│─────────│
# 0     ║ 0.1100  │ 0.2000  │
# 1     ║ 0.0900  │ 0.6000  │

Class

VariableElimination