Skip to contents

PottsGibbs: single-site raster-scan Gibbs sampler of \(P(x) \propto \exp(\beta \sum_{i \sim j} 1(x_i = x_j))\) on a free-boundary four-neighbour lattice (states 0..q-1; Ising with coupling \(J\) is q = 2, \(\beta = 2J\)), full conditionals drawn by inversion of Philox uniforms (stream = sweep); returns the final lattice and per-sweep like-pair counts and state-0 shares. PottsExact: log partition function and moments of the like-pair count by enumeration (small lattices). Identical to the Python arm morie.fn.pppextra (Potts 1952; Geman and Geman 1984).

Usage

PottsGibbs(nrow, ncol, q, beta, sweeps = 100L, seed = 1, init = NULL)

PottsExact(nrow, ncol, q, beta)

Arguments

nrow, ncol

Lattice size.

q

Number of states.

beta

Interaction.

sweeps

Number of sweeps.

seed

Philox seed.

init

Optional initial lattice (matrix of states).

Value

List.

References

Potts, R. B. (1952). Some generalized order-disorder transformations. Mathematical Proceedings of the Cambridge Philosophical Society 48, 106-109.

Geman, S. and Geman, D. (1984). Stochastic relaxation, Gibbs distributions, and the Bayesian restoration of images. IEEE PAMI 6, 721-741.

Examples

PottsExact(1, 2, 2, 0)$mean_like_pairs
#> [1] 0.5
PottsGibbs(3, 3, 2, 50, sweeps = 5, init = matrix(0, 3, 3))$like_pairs
#> [1] 12 12 12 12 12