दोनों अवधारणाओं के बीच संबंध है कि मार्कोव श्रृंखला मोंटे कार्लो (उर्फ एमसीएमसी) तरीके मार्कोव श्रृंखला सिद्धांत पर भरोसा करते हैं एक जटिल लक्ष्य वितरण से सिमुलेशन और मोंटे कार्लो अनुमानों का उत्पादन करने के ।π
X1,…,XNXi{Xi−1,…,X1}Xi−1
Xi=f(Xi−1,ϵi)
fπϵiXiπi∞
MCMC एल्गोरिथ्म का सबसे आसान उदाहरण स्लाइस नमूना है : इस एल्गोरिथ्म के पुनरावृत्ति i पर, करते हैं
- ϵ1i∼U(0,1)
- Xi∼U({x;π(x)≥ϵ1iπ(Xi−1)}) (which
amounts to generating a second independent ϵ2i)
For instance, if the target distribution is a normal N(0,1) [for which you obviously would not need MCMC in practice, this is a toy example!] the above translates as
- simulate ϵ1i∼U(0,1)
- simulate Xi∼U({x;x2≤−2log(2π−−√ϵ1i}),
i.e., Xi=±ϵ2i{−2log(2π−−√ϵ1i)φ(Xi−1)}1/2
with ϵ2i∼U(0,1)
or in R
T=1e4
x=y=runif(T) #random initial value
for (t in 2:T){
epsilon=runif(2)#uniform white noise
y[t]=epsilon[1]*dnorm(x[t-1])#vertical move
x[t]=sample(c(-1,1),1)*epsilon[2]*sqrt(-2*#Markov move from
log(sqrt(2*pi)*y[t]))}#x[t-1] to x[t]
Here is a representation of the output, showing the right fit to the N(0,1) target and the evolution of the Markov chain (Xi).
And here is a zoom on the evolution of the Markov chain (Xi,ϵ1iπ(Xi)) over the last 100 iterations, obtained by
curve(dnorm,-3,3,lwd=2,col="sienna",ylab="")
for (t in (T-100):T){
lines(rep(x[t-1],2),c(y[t-1],y[t]),col="steelblue");
lines(x[(t-1):t],rep(y[t],2),col="steelblue")}
that follows vertical and horizontal moves of the Markov chain under the target density curve.