Learn R Programming

PottsUtils (version 0.2-1)

SW: 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 in a graph.
ncolor
number of colors each vertex can take.
edges
edges in a graph.
weights
weights of edges. One for each corresponding edge in edges. The default values are 1s for all.
beta
the parameter inverse temperature of the Potts model.

Value

  • The output is a nvertex*n matrix with the kth column being the kth sample.

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.

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

Wolff, BlocksGibbs

Examples

Run this code
#Example 1: Generate 100 samples from a Potts model with the
  #           neighborhood structure corresponding to a
  #           second-order Markov random field defined on a 
  #           \eqn{3 \times 3} 2D graph. The number of colors is 2.
  #           \eqn{\beta}=0.1. All weights are equal to 1.
 
  edges <- getEdges(mask=matrix(1, 3, 3), neiStruc=rep(2,4))
  SW(n=100, nvertex=9, ncolor=2, edges, beta=0.1)

Run the code above in your browser using DataLab