WeightedSampling.posterior

WeightedSampling.posterior(*args)

Computes and returns the posterior of a node.

Parameters:
  • var (int) – the node Id of the node for which we need a posterior probability

  • nodeName (str) – the node name of the node for which we need a posterior probability

Returns:

a const ref to the posterior probability of the node

Return type:

pyagrum.Tensor

Raises:

pyagrum.UndefinedElement – If an element of nodes is not in targets

Example

import pyagrum as gum

bn = gum.fastBN("A->B<-C", uniform=True)
ie = gum.WeightedSampling(bn)
ie.setEvidence({"A": 1})
ie.makeInference()
ie.posterior("A").tolist()
# [0.0, 1.0]
round(ie.posterior("B").sum(), 4)
# 1.0

Class

WeightedSampling

Overridden in

LoopyWeightedSampling.posterior