Simulate pixel labels using chequerboard Gibbs sampling.

mcmcPottsNoData(beta, k, neighbors, blocks, niter = 1000, random = TRUE)

Arguments

beta

The inverse temperature parameter of the Potts model.

k

The number of unique labels.

neighbors

A matrix of all neighbors in the lattice, one row per pixel.

blocks

A list of pixel indices, dividing the lattice into independent blocks.

niter

The number of iterations of the algorithm to perform.

random

Whether to initialize the labels using random or deterministic starting values.

Value

A list containing the following elements:

alloc

An n by k matrix containing the number of times that pixel i was allocated to label j.

z

An (n+1) by k matrix containing the final sample from the Potts model after niter iterations of chequerboard Gibbs.

sum

An niter by 1 matrix containing the sum of like neighbors, i.e. the sufficient statistic of the Potts model, at each iteration.

See also

BlocksGibbs

Examples

# Swendsen-Wang for a 2x2 lattice neigh <- matrix(c(5,2,5,3, 1,5,5,4, 5,4,1,5, 3,5,2,5), nrow=4, ncol=4, byrow=TRUE) blocks <- list(c(1,4), c(2,3)) res.Gibbs <- mcmcPottsNoData(0.7, 3, neigh, blocks, niter=200) res.Gibbs$z
#> [,1] [,2] [,3] #> [1,] 1 0 0 #> [2,] 0 0 1 #> [3,] 1 0 0 #> [4,] 1 0 0 #> [5,] 0 0 0
res.Gibbs$sum[200]
#> [1] 2