BlocksGibbs {PottsUtils} | R Documentation |
Generate Random Samples from a Potts Model Using the Checkerboard Idea
Description
Generate random samples from a Potts model by Gibbs Sampling that takes advantage of conditional independence.
Usage
BlocksGibbs(n, nvertex, ncolor, neighbors, blocks,
weights=1, spatialMat=NULL, beta)
Arguments
n |
number of samples. |
nvertex |
number of vertices in a graph. |
ncolor |
number of colors each vertex can take. |
neighbors |
a matrix of all neighbors in a graph, one row per vertex. |
blocks |
a list of blocks of vertices in a graph. |
weights |
weights between neighbors. One for each corresponding
neighbor in |
spatialMat |
the matrix that describes the relationship among
vertices in neighbor. The default value is |
beta |
the parameter inverse temperature of the Potts model. |
Details
We use the Gibbs algorithm that takes advantage of conditional independence to speed up the generation of random samples from a Potts model. The idea is that if we can divide variables that need to be updated into different blocks and given the variables in other blocks, all the variables within the same block are conditionally independent, then we can update all blocks iteratively with the variables within the same block being updated simultaneously.
The spatialMat
is the argument used to specify the
relationship among vertices in neighbor. See
rPotts1
for more information on the Potts
model and spatialMat
.
Value
The output is a nvertex
by n
matrix with
the kth column being the kth sample.
References
Dai Feng (2008) Bayesian Hidden Markov Normal Mixture Models with Application to MRI Tissue Classification Ph. D. Dissertation, The University of Iowa
See Also
Examples
#Example 1: Generate 100 samples from a repulsion Potts model with the
# neighborhood structure corresponding to a first-order
# Markov random field defined on a 3*3 2D graph.
# The number of colors is 3 and beta=0.1,a_1=2,a_2=1,a_3=0.
# All weights are equal to 1.
neighbors <- getNeighbors(mask=matrix(1, 3, 3), neiStruc=c(2,2,0,0))
blocks <- getBlocks(mask=matrix(1, 3, 3), nblock=2)
spatialMat <- matrix(c(2,1,0, 1,2,1,0,1,2), ncol=3)
BlocksGibbs(n=100, nvertex=9, ncolor=3, neighbors=neighbors, blocks=blocks,
spatialMat=spatialMat, beta=0.1)