Posterior P(query given evidence) by sum-product variable elimination: every conditional probability table becomes a factor, evidence rows are selected out, each hidden non-query variable is summed out of the product of the factors that mention it, and the surviving factors are multiplied and normalized. The elimination order is lexicographic over the hidden variables – deterministic, identical to the Python arm, and the order affects only cost, never the result.
References
Zhang, N. L. and Poole, D. (1994). A simple approach to Bayesian network computations. Proc. 10th Canadian Conference on AI, 171-178.
Pearl, J. (1988). Probabilistic Reasoning in Intelligent Systems. Morgan Kaufmann.
Koller, D. and Friedman, N. (2009). Probabilistic Graphical Models. MIT Press, Ch. 9.
Examples
graph <- list(C = character(0), R = "C")
cpts <- list(C = c(0.5, 0.5), R = list(c(0.8, 0.2), c(0.2, 0.8)))
Baynet(graph, cpts, list(), "R")
#> $posterior
#> [1] 0.5 0.5
#>
#> $states
#> [1] 2
#>
#> $estimate
#> [1] 0
#>
#> $normalizer
#> [1] 1
#>
#> $query
#> [1] "R"
#>
#> $method
#> [1] "Variable elimination (Zhang-Poole 1994), lexicographic order"
#>
