Learn R Programming

bayess (version 1.4)

pottshm: Metropolis-Hastings sampler for a Potts model with ncol classes

Description

This function returns a simulation of a n by m grid from a Potts distribution with ncol colours and a four neighbour structure, using a Metropolis-Hastings step that avoids proposing a value identical to the current state of the Markov chain.

Usage

pottshm(ncol=2,niter=10^4,n,m=n,beta=0)

Arguments

ncol
number of colors
niter
number of Metropolis-Hastings iterations
n
number of rows in the image
m
number of columns in the image
beta
parameter of the Potts model

Value

returns a random realisation from the Potts model

See Also

pottsgibbs

Examples

Run this code
ex=pottshm(niter=50,n=15,beta=.4)
hist(ex,prob=TRUE,col="steelblue",main="pottshm()")

Run the code above in your browser using DataLab