An example of a Bayesian network is:
where are the parents of node i in a DAG.
The same probability distribution can be represented as a Markov random field:
The probability distribution of a Markov random field factorizes as:
where are the cliques of an undirected graph,
are "potentials" or "compatibility functions", and
is the partition sum which properly normalizes the probability distribution.
Finally, the same probability distribution can be represented as a factor graph:
The probability distribution of a factor graph factorizes as:
where are the factor nodes of a factor graph (a bipartite graph consisting of variable nodes and factor nodes),
are the factors, and
is the partition sum which properly normalizes the probability distribution.
Looking at the expressions for the joint probability distributions, it is obvious that Bayesian networks and Markov random fields can both be easily represented as factor graphs. Factor graphs most naturally express the factorization structure of a probability distribution, and hence are a convenient representation for approximate inference algorithms, which all try to exploit this factorization. This is why libDAI uses a factor graph as representation of a graphical model, implemented in the dai::FactorGraph class.
libDAI offers several inference algorithms, which solve (a subset of) these tasks either approximately or exactly, for factor graphs with discrete variables. The following algorithms are implemented:
Exact inference:
Approximate inference:
Not all inference tasks are implemented by each method: calculating MAP states is only possible with dai::JTree, dai::BP and dai::DECMAP; calculating partition sums is not possible with dai::MR, dai::LC and dai::Gibbs.
We use the following notational conventions. The discrete random variable with label is denoted as
, and the number of possible values of this variable as
or simply
. The set of possible values of variable
is denoted
and called its state space.
The canonical ordering of the variables in A is induced by their labels. That is: if , then
occurs before
in the canonical ordering. Below, we will assume that
is ordered according to the canonical ordering, i.e.,
.
A state of n variables can be represented as an n-tuple of non-negative integers: corresponds to the joint assignment
. Alternatively, a state can be represented compactly as one non-negative integer; this representation is called a linear state. The linear state s corresponding to the state
would be:
Vice versa, given a linear state s for the variables A, the corresponding state of the i 'th variable
(according to the canonical ordering of the variables in A) is given by
Finally, the number of states of the set of variables A is simply the number of different joint assignments of the variables, that is, .