GibbsSampling.currentPosterior
- GibbsSampling.currentPosterior(*args)
Returns the current estimation of the posterior of a node (for instance during the inference, in a listener). It is the evidence for an observed node. Unlike
posterior, this method does not start the inference and accepts a node which is not a target.- Parameters:
id (
int) – the node Id of the node for which we need a posterior probabilityname (
str) – the node name of the node for which we need a posterior probability
- Returns:
a const ref to the current posterior probability of the node
- Return type:
- Raises:
pyagrum.NotFound – If the node does not belong to the Bayesian network, or if it is not observed and no estimation exists yet (inference not started)
Example
import pyagrum as gum
bn = gum.fastBN("A->B")
bn.cpt("A").fillWith([0.2, 0.8])
bn.cpt("B")[:] = [[0.9, 0.1], [0.3, 0.7]]
gum.initRandom(42)
ie = gum.GibbsSampling(bn)
ie.setEpsilon(1e-2)
ie.makeInference()
ie.currentPosterior("B").names # during inference (e.g. in a listener), it gives the current estimate
# ('B',)
ie.currentPosterior("B").tolist() == ie.posterior("B").tolist() # after inference: the posterior
# True
Class
Overridden in