VariableElimination.jointPosterior
- VariableElimination.jointPosterior(targets)
Compute the joint posterior of a set of nodes.
- Parameters:
list – the list of nodes whose posterior joint probability is wanted
Warning
The order of the variables given by the list here or when the jointTarget is declared can not be assumed to be used by the Tensor.
- Returns:
a const ref to the posterior joint probability of the set of nodes.
- Return type:
- Raises:
pyagrum.UndefinedElement – If an element of nodes is not in targets
- Parameters:
targets (
object)
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", "B"})
ie.setEvidence({"C": 1})
print(ie.jointPosterior({"A", "B"}).reorganize(["A", "B"])) # fixed order of the variables
#
# ║ A │
# B ║0 │1 │
# ──────║─────────│─────────│
# 0 ║ 0.1043 │ 0.1391 │
# 1 ║ 0.0261 │ 0.7304 │
Class