Bayesian networks
A Bayesian network is a probabilistic model represented by a direct acyclic graph G = {V, E}, where the vertices are random variables Xi, and the edges determine a conditional dependence among them. In the following diagram, there's an example of a simple Bayesian network with four variables:
Example of Bayesian network
The variable X4 is dependent on X3, which is dependent on X1 and X2. To describe the network, we need the marginal probabilities P(X1) and P(X2) and the conditional probabilities P(X3 | X1, X2) and P(X4 | X3). In fact, using the chain rule, we can derive the full joint probability as:
The previous expression shows an important concept: as the graph is direct and acyclic, each variable is conditionally independent of all other variables that are not successors given its predecessors. To formalize this concept, we can define the function Predecessors(Xi), which returns the set of nodes that influence Xi directly, for example, Predecessors...