CNMonteCarloSampling.marginalMax
- CNMonteCarloSampling.marginalMax(*args)
Get the upper marginals of a given node id.
- Parameters:
id (
int) – the node id which upper marginals we want.varName (
str) – the variable name which upper marginals we want.
- Returns:
a tensor over the variable, with the upper bound of the probability of each of its values (after
makeInference).- Return type:
- Raises:
pyagrum.NotFound – If the node does not belong to the Credal network
Example
import pyagrum as gum
gum.initRandom(42)
bn = gum.fastBN("A->B")
bnmin, bnmax = gum.BayesNet(bn), gum.BayesNet(bn)
bnmin.cpt("A").fillWith([0.2, 0.6])
bnmax.cpt("A").fillWith([0.4, 0.8])
bnmin.cpt("B")[:] = [[0.1, 0.7], [0.5, 0.3]]
bnmax.cpt("B")[:] = [[0.3, 0.9], [0.7, 0.5]]
cn = gum.CredalNet(bnmin, bnmax)
cn.intervalToCredal()
ie = gum.CNMonteCarloSampling(cn)
ie.makeInference()
[round(p, 4) for p in ie.marginalMax("B").tolist()]
# [0.62, 0.66]
Class