Belief Propagation: 2D Ising Model on a Grid
A demonstration of the belief propagation algorithm for the Ising model on a grid.Ising Model Settings |
Belief Propagation Settings
|
Approximate Log Partition Function:
Description
In the figure above, each box represents a particle placed in a 2D grid. The particles interact only with particles that are adjacent to them in a north, south, east, or west direction. Each particle has an associated spin (+1 or -1). Given an assignment of spins, we compute the energy of the system as: $$E(x) = e^{1/T(\sum_i h_ix_i + \sum_{ij} J_{ij}x_ix_j)}$$ In the above, each element of the vector x has a value of either +1 or -1. When studying the properties of such a system, one quatity of interest is the partition function: $$Z = \sum_{x\in\{-1,1\}^n} E(x)$$ In general, computing Z can be computationally expensive (in fact, it's known to be NP-hard). As a result, we will usually settle for a good approximation. The belief propagation algorithm (BP) is an iterative message passing scheme over a given graphical model. The goal of the algorithm is to perform approximate inference. In this example, we use it to approximate the partition function of the energy function for the 2D Ising model. In addition to the partition function, BP also provides approximate marginals. In the above visualization, squares are colored by the approximate marginal probabilities produced by the BP algorithm: the percentage of red is give by the marginal probability of +1 at that node and the percentage of blue is given by the marginal probability for -1. Here, we employ the standard BP update equations with damping. The message passed from a node i to its neighbor j at the nth step of the algorithm is given by the following equation:Things to Try
BP Settings
Many of the characteristics of the belief propagation algorithm can be observed by tweaking the BP settings above. For example, with damping set to 1, the standard BP update often oscillates without converging. Also, try pressing the random initialization button a few times: the algorithm may converge to different fixed points. Even after convergence, the value of the esitmate may oscillate in a small range due to numerical issues.The Ising Model
Try adjusting the values of J while holding h fixed: positive J encourages neighboring spins to align while negative J has the opposite effect.Other observations are as follows: