Computational Physics - Department of Physics

(Axel Boer) #1

406 12 Random walks and the Metropolis algorithm


Initialize:
Establish an
initial state,
for example
a positionx(i)

Suggest
a moveyt

Compute ac-
ceptance ratio
A(x(i)→yt)

Generate a
uniformly
distributed
variabler

Is
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 values

Last
MC
step?

Collect
samples

End

yes

no

yes

yes

no

Fig. 12.7Chart flow for the Metropolis algorithm.

Free download pdf