In [1]:
%load_ext autoreload
%autoreload 2
from xymodel import *
In [13]:
# MxM example at approx. critical temp
M = 16
X = classicalXY(16,1.1)
In [8]:
# Using standard IS with uniform proposal (does not appear in the paper)
samplesIS = 1000
X.importanceSampling(samplesIS)
Out[8]:
In [25]:
# Using AIS with linear temperature scale (Matlab version used in paper)
samplesAIS = 100
beta = linspace(0,1,100)
X.annealedImportanceSampling(beta, samplesAIS)
Out[25]:
The following code shows implementation examples of Random neighbour and Left-Right that appears in the paper "Sequential Monte Carlo for Graphical Models" by Naesseth et. al. (2014).
In [17]:
# Using random neighbour SMC for PGM
particles = 1000
index = arange(M**2)
random.shuffle(index)
X.smc(index,particles,NT=0.6,resamp='sys')
Out[17]:
In [24]:
# Using left-right SMC for PGM
particles = 1000
index = np.arange(M**2)
X.smc(index,particles,NT=0.6,resamp='sys')
Out[24]:
In [24]: