BayesNet.addNoisyOR

BayesNet.addNoisyOR(*args)

Add a variable, it’s associate node and a noisyOR implementation.

Since it seems that the ‘classical’ noisyOR is the Compound noisyOR, we keep the addNoisyOR as an alias for addNoisyORCompound.

(The id of the new variable can be automatically generated.)

Parameters:
  • variable (pyagrum.DiscreteVariable) – The variable added by copy

  • externalWeight (float) – the added external weight

  • id (int) – The proposed id for the variable.

Returns:

the id of the added variable.

Return type:

int

Raises:

pyagrum.DuplicateElement – If id is already used

Example

import pyagrum as gum

bn = gum.fastBN("A;B")
bn.addNoisyOR(gum.LabelizedVariable("C", "noisy OR", 2), 0.0)
# 2
bn.addWeightedArc("A", "C", 0.8)
bn.addWeightedArc("B", "C", 0.6)
round(float(bn.cpt("C")[{"A": 1, "B": 1}][1]), 4)  # 1 - (1 - 0.8) * (1 - 0.6)
# 0.92

Class

BayesNet