Artificial Intelligence A Modern Approach (3rd Edition): Figure 14.11, page 528.
function ELIMINATION-ASK(X, e, bn) returns a distribution over X inputs: X, the query variable e, observed values for variables E bn, a Bayesian network specifying joint distribution P(X1, ..., Xn) factors <- [] for each var in ORDER(bn.VARS) do factors <- [MAKE-FACTOR(var, e) | factors] if var is hidden variable the factors <- SUM-OUT(var, factors) return NORMALIZE(POINTWISE-PRODUCT(factors))
Figure 14.11 The variable elimination algorithm for inference in Bayesian networks.
Note: The implementation has been extended to handle queries with multiple variables.
@author Ciaran O'Reilly