LoopyImportanceSampling.chgEvidence
- LoopyImportanceSampling.chgEvidence(*args)
Change the value of an already existing 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 IdnodeName (
str) – a node nameval (
int | str) – a node value or the label of the node valuevals (
listoffloat) – a list of values
- Raises:
pyagrum.InvalidArgument – If the node does not already have an evidence
pyagrum.InvalidArgument – If val is not a value for the node
pyagrum.InvalidArgument – If the size of vals is different from the domain side of the node
pyagrum.InvalidArgument – If a value of vals is negative or not finite, or if vals is a vector of 0s (the evidence is not changed)
pyagrum.FatalError – If the evidence is soft and the inference is a sampling one (the evidence is not changed)
pyagrum.UndefinedElement – If the node does not belong to the Bayesian network
- Return type:
None
Example
import pyagrum as gum
bn = gum.fastBN("A->B<-C", uniform=True)
ie = gum.LoopyImportanceSampling(bn)
ie.addEvidence("A", 0)
ie.chgEvidence("A", 1)
ie.makeInference()
ie.posterior("A").tolist()
# [0.0, 1.0]
Class