406 12 Random walks and the Metropolis algorithm
Initialize:
Establish an
initial state,
for example
a positionx(i)Suggest
a moveytCompute ac-
ceptance ratio
A(x(i)→yt)Generate a
uniformly
distributed
variablerIs
A(x(i)→
yt)≥r?Reject move:
x(i+^1 )=x(i)Accept move:
x(i)=yt=x(i+^1 )Last
move?Get local
expecta-
tion valuesLast
MC
step?Collect
samplesEndyesnoyesyesnoFig. 12.7Chart flow for the Metropolis algorithm.