LoopyWeightedSampling.addEvidence

LoopyWeightedSampling.addEvidence(*args)

Adds a new evidence on a node (might be soft or hard).

The sampling inferences (Gibbs, Monte Carlo, Weighted, Importance and their loopy versions) accept only hard evidence.

Parameters:
  • id (int) – a node Id

  • nodeName (str) – a node name

  • val – (int) a node value

  • val – (str) the label of the node value

  • vals (list[float]) – a list of values

Raises:
Return type:

None

Example

import pyagrum as gum

bn = gum.fastBN("A->B<-C", uniform=True)
ie = gum.LoopyWeightedSampling(bn)
ie.addEvidence("A", 1)  # by index
ie.addEvidence("C", "0")  # by label
sorted(ie.hardEvidenceNodes())
# [0, 2]
ie.makeInference()
ie.posterior("A").tolist()
# [0.0, 1.0]

Class

LoopyWeightedSampling