BayesNetFragment.installMarginal

BayesNetFragment.installMarginal(*args)

Install a local marginal for a node. Doing so, it removes the parents of the node in the fragment.

Parameters:
  • n (int, str) – the id or the name of the variable.

  • pot (Tensor) – the Tensor (marginal) to install

Raises:

pyagrum.NotFound – if the node is not found.

Return type:

None

Example

import pyagrum as gum

bn = gum.fastBN("A->B->C")
fragment = gum.BayesNetFragment(bn)
fragment.installNode("B")
fragment.checkConsistency()  # A is not installed
# False
fragment.installMarginal("B", gum.Tensor().add(bn.variable("B")).fillWith([0.3, 0.7]))
fragment.checkConsistency()
# True
fragment.cpt("B").tolist()
# [0.3, 0.7]

Class

BayesNetFragment