Homepage > MCMC

Metropolis Algorithm

Here we use random beta walk as a proposal chain, and run the Metropolis-Hastings Algorithm to generate a density of interest on $ [0,1]$. Execute metro.r at the R command prompt.
> source("metro.r")
> sample = bwalk.metro(ff=nm, run.time=100, delta=0.8, theta=20, sample.size=500)
> hist(sample, freq=F, breaks=seq(0,1,by=0.05), col="red")
> x = seq(0,1,by=0.05)
> lines(x, nm(x))

Explore it. Change the running time and the parameters for random beta walk, and see how the histogram differs from the target distribution of normal mixture.


© TTU Mathematics