Description Usage Arguments References Examples
View source: R/SwendsenWangAlg.R
This function allows you to simulate a Potts model using the Swendsen-Wang algorithm.
1 2 | SwendsenWangAlg(beta, Coord = NULL, Neigh_Bonds = NULL, col.obs,
Nrun = 10, sampling = "else")
|
beta |
parameters of the Potts model. |
Coord |
Matrix of coordinates. |
col.obs |
Binary matrix of colors. |
Nrun |
Number of MCMC runs. |
sampling |
Choice of sampling for the components. |
Wang, J. and Swendsen, R. (1990) Cluster Monte Carlo algorithms. Physica A: Statistical Mechanics and its Applications 167 565–579.
1 2 3 4 5 6 7 8 9 10 11 12 | beta = c(0.5,0.5,0.5)
Obs.loc = expand.grid(1:50,1:50)
id.pos = sample(1:3, 2500, replace = T)
Res20 = SwendsenWangAlg(beta, Coord = as.matrix(Obs.loc), col.obs = id.pos, Nrun = 20)
Res50 = SwendsenWangAlg(beta, Coord = as.matrix(Obs.loc), col.obs = id.pos, Nrun = 50)
Res500 = SwendsenWangAlg(beta, Coord = as.matrix(Obs.loc), col.obs = id.pos, Nrun = 500)
par(mfrow = c(2,2))
col = grey.colors(3)
image(matrix(Res20$col.old, ncol = 50), col = col)
image(matrix(Res20$col.new, ncol = 50), col = col)
image(matrix(Res50$col.new, ncol = 50), col = col)
image(matrix(Res500$col.new, ncol = 50), col = col)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.