libDAI
|
Commonly used graphical models are Bayesian networks and Markov random fields. In libDAI, both types of graphical models are represented by a slightly more general type of graphical model: a factor graph [KFL01].
An example of a Bayesian network is:
The probability distribution of a Bayesian network factorizes as:
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.
Given a factor graph, specified by the variable nodes the factor nodes , the graph structure, and the factors , the following tasks are important:
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.
In addition, libDAI supports parameter learning of conditional probability tables by Expectation Maximization (or Maximum Likelihood, if there is no missing data). This is implemented in dai::EMAlg.
Linear states are a concept that is used often in libDAI, for example for storing and accessing factors, which are functions mapping from states of a set of variables to the real numbers. Internally, a factor is stored as an array, and the array index of an entry corresponds with the linear state of the set of variables. Below we will define variables, states and linear states of (sets of) variables.
Each (random) variable has a unique identifier, its label (which has a non-negative integer value). If two variables have the same label, they are considered as identical. A variable can take on a finite number of different values or states.
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.
Let be a set of variables.
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 the variables in A refers to a joint assignment of the variables, or in other words, to an element of the Cartesian product of the state spaces of the variables in A. Note that a state can also be interpreted as a mapping from variables (or variable labels) to the natural numbers, which assigns to a variable (or its label) the corresponding state of the variable.
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, .