libDAI - A free and open source C++ library for Discrete Approximate Inference in graphical models

Joris Mooij
My email addres: user@domain, where user=joris.mooij and


About libDAI

libDAI is a free/open source C++ library that provides implementations of various (approximate) inference methods for discrete graphical models. libDAI supports arbitrary factor graphs with discrete variables; this includes discrete Markov Random Fields and Bayesian Networks.

The library is targeted at researchers. To be able to use the library, a good understanding of graphical models is needed.

The best way to use libDAI is by writing C++ code that invokes the library; in addition, part of the functionality is accessibly by using the

libDAI can be used to implement novel (approximate) inference algorithms and to easily compare the accuracy and performance with existing algorithms that have been implemented already.

A solver using libDAI was amongst the three winners of the UAI 2010 Approximate Inference Challenge. The full source code is provided as part of the library.


Currently, libDAI supports the following (approximate) inference methods:

These inference methods can be used to calculate partition sums, marginals over subsets of variables, and MAP states (the joint state of variables that has maximum probability).

In addition, libDAI supports parameter learning of conditional probability tables by Expectation Maximization.


libDAI is not intended to be a complete package for approximate inference. Instead, it should be considered as an "inference engine", providing various inference methods. In particular, it contains no GUI, currently only supports its own file format for input and output (although it can read files in FastInf format and in the formats used by the UAI 2010 Approximate Inference Challenge and the Probablistic Inference Evaluation, and more formats may be added later), and provides very limited visualization functionalities. The only learning method supported currently is Expectation Maximization (or Maximum Likelihood if no data is missing) for learning factor parameters.


In my opinion, the lack of open source "reference" implementations hampers progress in research on approximate inference. Methods differ widely in terms of quality and performance characteristics, which also depend in different ways on various properties of the graphical models. Finding the best approximate inference method for a particular application therefore often requires empirical comparisons. However, implementing and debugging these methods takes a lot of time which could otherwise be spent on research. I hope that this code will aid researchers to be able to easily compare various (existing as well as new) approximate inference methods, in this way accelerating research and stimulating real-world applications of approximate inference.


Because libDAI is implemented in C++, it is very fast compared with implementations in MatLab (a factor 1000 faster is not uncommon). libDAI does provide a (limited) MatLab interface for easy integration with MatLab. It also provides a command line interface and experimental python and octave interfaces (thanks to Patrick Pletscher).


The code has been developed under Debian GNU/Linux with the GCC compiler suite. libDAI compiles successfully with g++ versions 3.4 up to 4.6.

libDAI has also been successfully compiled with MS Visual Studio 2008 under Windows (but not all build targets are supported yet) and with Cygwin under Windows.

Finally, libDAI has been compiled successfully on MacOS X.


libDAI is licensed under the BSD 2-clause license (also known as the FreeBSD license).


If you write a scientific paper describing research that made substantive use of this library, please cite the following paper describing libDAI:

Joris M. Mooij;
libDAI: A free & open source C++ library for Discrete Approximate Inference in graphical models;
Journal of Machine Learning Research, 11(Aug):2169-2173, 2010.

In BiBTeX format (for your convenience):

    author    = {Joris M. Mooij},
    title     = {lib{DAI}: A Free and Open Source {C++} Library for Discrete Approximate Inference in Graphical Models},
    journal   = {Journal of Machine Learning Research},
    year      = 2010,
    month     = Aug,
    volume    = 11,
    pages     = {2169-2173},
    url       = ""

Moreover, as a personal note, I would appreciate it to be informed about any publications using libDAI (simply send an email to joris dot mooij at libdai dot org).


Development version

The newest libDAI version can be obtained from bitbucket at

You can use git to get the latest development version as follows:

git clone

which will create a local git repository in a directory named 'libdai', containing the libDAI source files. Updating the local repository can be done by issuing git pull from this directory.

MIGRATION On September 24, 2015, the libDAI repository migrated to a new host (more precisely, from to If you would like to continue to get updates via 'git pull', you can use the following commands to switch to the new upstream location:

git remote add new-origin
git remote rm origin
git remote rename new-origin origin
git branch --set-upstream-to=origin/master


Archive of releases:

Releases can also be obtained from MLOSS.


The ChangeLog documents changes between releases.


Documentation is provided in doxygen format. An online version is available as well.

Mailing list

The Google group libDAI can be used for getting support and discussing development issues.


libDAI was written by Joris M. Mooij with the help of the following people:

Smaller contributions (bug fixes and miscellaneous smaller patches) have been made by: Claudio Lima, Christian Wojek, Sebastian Nowozin, Stefano Pellegrini, Ofer Meshi, Dan Preston, Peter Gober, Jiuxiang Hu, Peter Rockett, Dhruv Batra, Alexander Schwing, Alejandro Lage, Matt Dunham, Laurens van der Maaten, Jerome Maye, Priya, Hynek Urban, Avneesh Saluja, Thomas Mensink, Julien Rebetez, Kyle Ellrott.


Part of this work is part of the Interactive Collaborative Information Systems (ICIS) project, supported by the Dutch Ministry of Economic Affairs, grant BSIK03024.

Other software projects using libDAI

Some other software projects that use libDAI are:

If you have released software that uses libDAI and would like to have your project listed here, just send me an email.


Valid XHTML 1.1! Valid CSS!