Université Paris Dauphine Département MIDO
Master 2 MASH – Computational methods and MCMC
2021–2022
Practical n°2
Markov Chain Monte Carlo
contact: stoehr@ceremade.dauphine.fr
Objectives. The Ising model has encountered quite a success in various applications such as electromagnetism or image processing. The model corresponds toX=(X1, . . . ,Xn) a discrete ran- dom process taking values inX ={−1, 1}nand defined on an undirected graphG which induces a topology onS ={1, . . . ,n}: by definition, (i,j)∈S are adjacent or neighbour (we denote it i ∼ j) if and only ifi and j are linked by an edge in G. We denoteN (i) the set of neighbors ofi∈S. In this practical, we are interested in two adjacency structure represented below: the four closest neighbours graph (a) and the eight closest neighbours graph (b) – neighbours of the vertex in black are represented by vertices in gray.
(a) (b)
Given a parameterβ∈R, the joint distribution of the model is given by
f(x|β)= 1 Z(β)exp
à βX
i∼j
xixj
! .
The Ising model faces computational issues since the normalising constant
Z(β)= X
x∈X
exp Ã
βX
i∼j
xixj
!
cannot be evaluated with standard analitycal or numerical methods (the sum ranges over 2N terms, where N is the number of nodes in G). Sampling from the likeliood and performing Bayesian analysis of such a model might thus be of a daunting task. In what follows we will see some Monte Carlo solutions.
Exercise 1. For an Ising model, the conditional distribution of a node ofG,i.e.
P£ Xi=xi
¯
¯β,Xj=xj,j6=i¤
= exp¡
βP
j∈N(i)xixj¢ exp¡
−βP
j∈N(i)xj¢ +exp¡
βP
j∈N(i)xj¢, (1)
1
Practical n°2 2021–2022
is easy to compute. A natural method to sample from the distribution is then the Gibbs sampler [1].
The Gibbs sampler addresses each componentxi in turn and updates it according to its conditional distribution (1). We assume in this exercise we have a four closest neighbours graph.
1. Write a functionpcond(x, i, beta)which computes the conditional distribution (1).
2. Write a functiongibbs_sampling(n, beta)which samples from the Ising model with parameter betausing the Gibbs sampler. The sampler can be initialised usingx=(1, . . . , 1).
3. Sample a realisation from an Ising model defined on a 30×30 grid with parameterβ=1 andβ=0.6 (n = 50). What do you observe?
Exercise 2(ABC model choice). Another question of interest when dealing with the Ising model is to select the dependency structureG that best fits an observed datasetxobs,i.e., we aim at finding the maximuma posteriori
mb=arg max
m∈M π(m|xobs)∝π(m) Z
Θm
fm(xobs|θm)πm(θm)dθm,
M={m: 1, . . . ,M} is a set of model,π(·) a prior on the model spaceM,πma prior on parameter space Θm associated to modelmand fm(· |θm) the likelihood of modelm.
To approximatem, ABC starts by simulating numerous triplets (m,b βm,x) from the joint Bayesian model.
Afterwards, it approximates the posterior probabilities by the frequency of each model number associ- ated with simulatedx’s in a neighbourhood ofxobs. The neighbourhood ofxobsis defined as simulations whose distances to the observation measured in terms of summary statistics,i.e. ρ©
S(x),S(xobs)ª , fall below a threshold².
ABC in theory.
1. What is the pseudo-target of ABC model choice algorithm. Give the estimate of the posterior model distribution obtained at the end of algorithm.
2. Justify that ifSis sufficent and²=0, then the method converges towards the posterior model distri- bution.
SelectingG. In this example, we set the prior on model indexπ(·) to the uniform distribution on {1, 2}, the prior on parameter space for modelm=1 to the uniform distribution on [0 , 1] and the one for modelm=2 to the uniform distribution on [0 , 0.5]. The distanceρis chosen to be the L2-standardised distance. Finally we use the vector of summary statistics composed of the summary statistic S(x)= Pi∼jxixj under each model which is sufficient for the model choice problem [2].
3. Write a functionsum_stat(x)which, given a pseudo-observationxreturns a vector composed of the summary statisticS(x)=P
i∼jxixjunder each model.
4. Write a function abc_ref_table(n, m, h, w)which drawsn particles from the joint Bayesian model usingmiterations of the Gibbs sampler and returns a table containing model indices, param- eter values and summaries of the generated data.
5. We set to 100 the number of iterations of the Gibbs sampler.
(a) Draw a pseudo-observationxobsfrom an Ising model defined on a 20×20 grid with a four closest neighborhood structure atβ=0.5.
2
Practical n°2 2021–2022
(b) Perform ABC model choice for the pseudo-observationxobsby keeping the 100 closest simula- tions with respect to the L2-standardised distance on a reference table of size 10000.
References
[1] S. Geman and D. Geman. Stochastic Relaxation, Gibbs Distributions, and the Bayesian Restoration of Images.IEEE Transactions on Pattern Analysis and Machine Intelligence, 6(6):721–741, 1984.
[2] A. Grelaud, C. P. Robert, J.-M. Marin, F. Rodolphe, and J.-F. Taly. ABC likelihood-free methods for model choice in Gibbs random fields.Bayesian Analysis, 4(2):317–336, 2009.
3