January 30, 2011 at 9:16 pm (Monte Carlo)
Tags: MCMC, Metropolis, Metropolis-Hasting, Riddle, simulated annealing
Yesterday, while reading the last issue of the NewScientist, I came across the following very cute riddle:
Lazy, I asked myself if it were possible to write lines long Python code to solve this innocent looking enigma. The whole pyramid is entirely determined by the numbers lying at the bottom, and each one of them is an integer between and : these numbers must be different so that there are at most possibilities to test! Brute force won’t work my friend!
When stupid brute force does not work, one can still try annealing/probabilist methods: this works pretty well for Sudoku (which is NP-hard) as this is brilliantly described here and there. The principle is simple: if one can find a good energy function such that a solution to the problem corresponds to a low energy configuration, one can do MCMC-simulating annealing-etc on the target distribution
The issue is that it might be very difficult to choose a sensible energy function . Foolishly, I first tried the following energy function, and then ran a random walk Metropolis algorithm with as target probability:
where is the numbers of levels that one can fill, starting from the bottom, without encountering any problem no repetition and no number greater than . With different values of and letting run the algorithm for a few millions iterations ( min on my crappy laptop), one can easily produce configurations that are -levels high: but the algorithm never found any real solution a configuration with height equal to .
Now I am curious wether this is possible to produce a non-stupid energy function so that this riddle is solvable in a reasonable amount of time by standard MCMC – annealing methods.
As a conclusion, I should mention that with a pen and a cup of coffee, one can easily find a solution: I will not spoil the fun, but just say that the configuration space is not that big if one think more carefully about it…
June 22, 2010 at 12:24 am (markov chain, Monte Carlo, probability)
Tags: Ising, MCMC, Metropolis, Monte Carlo, Potts model
A simple model of interacting particles
The mean field Potts model is extremely simple: there are interacting particles and each one of them can be in different states . Define the Hamiltonian
where and is the Kronecker symbol. The normalization ensures that the energy is an extensive quantity so that the mean energy per particle does no degenerate to or for large values of . The sign minus is here to favorize configurations that have a lot of particles in the same state. The Boltzman distribution at inverse temperature on is given by
where is a normalization constant. Notice that if we choose a configuration uniformly at random in , with overwhelming probability the ratio of particles in state will be close to . Also it is obvious that if we define
then will be close to for a configuration taken uniformly at random. Stirling formula even says that the probability that is close to is close to where
Indeed . The situation is quite different under the Boltzman distribution since it favorizes the configurations that have a lot of particles in the same state: this is because the Hamiltonian is minimized for configurations that have all the particles in the same state. In short there is a competition between the entropy (there are a lot of configurations close to the ratio ) and the energy that favorizes the configurations where all the particles are in the same state.
With a little more work, one can show that there is a critical inverse temperature such that:
- for the entropy wins the battle: the most probable configurations are close to the ratio
- for the energy effect shows up: there are most probable configurations that are the permutations of where and are computable quantities.
The point is that above the system has more than one stable equilibrium point. Maybe more important, if we compute the energy of these most probable states
then this function has a discontinuity at . I will try to show in the weeks to come how this behaviour can dramatically slow down usual Monte-Carlo approach to the study of these kind of models.
Hugo Touchette has a very nice review of statistical physics that I like a lot and a good survey of the Potts model. Also T. Tao has a very nice exposition of related models. The blog of Georg von Hippel is dedicated to similar models on lattices, which are far more complex that this mean field approximation presented here.
These is extremely easy to simulate this mean field Potts model since we only need to keep track of the ratio to have an accurate picture of the system. For example, a typical Markov Chain Monte Carlo approach would run as follows:
- choose a particle uniformly at random in
- try to switch its value uniformly in
- compute the Metropolis ratio
- update accordingly.
If we do that times for states at inverse temperature and for particles (which is fine since we only need to keep track of the -dimensional ratio vector) and plot the result in barycentric coordinates we get a picture that looks like:
Here I started with a configuration where all the particles were in the same states i.e ratio vector equal to . We can see that even with steps, the algorithm struggles to go from one most probable position to the other two and – in this simulation, one of the most probable state has even not been visited! Indeed, this approach was extremely naive, and this is quite interesting to try to come up with better algorithms. Btw, Christian Robert’s blog has tons of interesting stuffs related to MCMC and how to boost up the naive approach presented here.