https://github.com/stecrotti/beliefpropagation.jl
The Belief Propagation approximation for probability distributions on sparse graphs
https://github.com/stecrotti/beliefpropagation.jl
belief-propagation graphical-models inference markov-random-fields stat-mech
Last synced: 8 months ago
JSON representation
The Belief Propagation approximation for probability distributions on sparse graphs
- Host: GitHub
- URL: https://github.com/stecrotti/beliefpropagation.jl
- Owner: stecrotti
- License: mit
- Created: 2023-10-03T13:33:07.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-07-10T17:26:57.000Z (11 months ago)
- Last Synced: 2025-07-10T18:41:29.145Z (11 months ago)
- Topics: belief-propagation, graphical-models, inference, markov-random-fields, stat-mech
- Language: Julia
- Homepage:
- Size: 1.28 MB
- Stars: 25
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# BeliefPropagation
[](https://stecrotti.github.io/BeliefPropagation.jl/stable/)
[](https://stecrotti.github.io/BeliefPropagation.jl/dev/)
[](https://github.com/stecrotti/BeliefPropagation.jl/actions/workflows/CI.yml?query=branch%3Amain)
[](https://codecov.io/gh/stecrotti/BeliefPropagation.jl)
[](https://github.com/JuliaTesting/Aqua.jl)
This package implements a generic version of the [Belief Propagation](https://en.wikipedia.org/wiki/Belief_propagation) (BP) algorithm for the approximation of probability distributions factorized on a graph
```math
\begin{equation}
p(x_1,x_2,\ldots,x_n) \propto \prod_{a\in F} \psi_a(\underline{x}_a) \prod_{i\in V} \phi_i(x_i)
\end{equation}
```
where $F$ is the set of factors, $V$ the set of variables, and $\underline{x}_a$ is the set of variables involved in factor $a$.
## Installation
```julia
import Pkg; Pkg.add("BeliefPropagation")
```
## Quickstart
Check out the [examples](https://github.com/stecrotti/BeliefPropagation.jl/tree/main/examples) folder.
## Overview
The goal of this package is to provide a simple, flexible, and ready-to-use interface to the BP algorithm. It is enough for the user to provide the factor graph (encoded in an adjacency matrix or as a [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) graph) and the factors, everything else is taken care of.
At the same time, the idea is that refinements can be made to improve performance on a case-by-case basis. For example, messages are stored as `Vector`s by default, but when working with binary variables, one real number is enough, allowing for considerable speed-ups (see the [Ising](https://github.com/stecrotti/BeliefPropagation.jl/blob/9cbc01d6bbd0266531d6047482b8617bb6eb71ab/src/Models/ising.jl#L56) example).
Also, a version of BP for continuous variables such as Gaussian BP can be introduced in the framework, although it is not yet implemented.
## See also
- [BeliefPropagation.jl](https://github.com/ArtLabBocconi/BeliefPropagation.jl): implements BP for the Ising model and the matching problem.
- [FactorGraph.jl](https://github.com/mcosovic/FactorGraph.jl): implements Gaussian BP and other message-passing algorithms.
- [ITensorNetworks.jl](https://github.com/ITensor/ITensorNetworks.jl): implements BP as a technique for approximate tensor network contraction.
- [ReactiveMP.jl](https://github.com/ReactiveBayes/ReactiveMP.jl): allows to solve Bayesian inference problems using message-passing.
- [CodingTheory](https://github.com/esabo/CodingTheory/blob/93505402aa1add7d8bb5f06bce24f9fd2bd6a560/src/LDPC/MP_decoders.jl): has a specialized implementation of BP for the coding problem