SW {PottsUtils} | R Documentation |
Generate Random Samples from a Compound Potts Model by the Swendsen-Wang Algorithm
Description
Generate random samples from a compound Potts model using the Swendsen-Wang algorithm.
Usage
SW(n, nvertex, ncolor, edges, weights, beta)
Arguments
n |
number of samples. |
nvertex |
number of vertices of a graph. |
ncolor |
number of colors each vertex can take. |
edges |
edges of a graph. |
weights |
weights of edges. One for each corresponding component in
|
beta |
the parameter inverse temperature of the Potts model. |
Details
We use the Swendsen-Wang algorithm to generate random samples from a
compound Potts model. See rPotts1
for more
information on the compound Potts model.
Value
The output is a nvertex
by n
matrix with
the kth column being the kth sample.
References
Robert H. Swendsen and Jian-Sheng Wang (1987) Nonuniversal Critical Dynamics in Monte Carlo Simulations Physical Review Letters vol. 58, no. 2, 86-88
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 Potts model with the
# neighborhood structure corresponding to a
# second-order Markov random field defined on a
# 3*3 2D graph. The number of colors is 2.
# beta=0.1. All weights are equal to 1.
edges <- getEdges(mask=matrix(1, 2, 2), neiStruc=rep(2,4))
set.seed(100)
SW(n=500, nvertex=4, ncolor=2, edges, beta=0.8)