5.3 Sampling Method with the Detailed Balance
97
Note that the transition probability depends only on the difference of the energy.
In other words, if we change the state by some appropriate method and look at the
change in energy, we will know the transition probability. Since it is not necessary to
find the entire transition matrix (or the partition function), it is a versatile algorithm
that can be applied regardless of the number of states, if we do not question if it is
an optimal one.
The steps to execute the Metropolis method are summarized as follows:
1. First, prepare an appropriate state s 0 . Hereinafter, repeat i = 0, 1, 2, 3 · · · .
2. Calculate Hamiltonian (= H [s i ]) at s i .
3. Change the state s i to s candidate by some means.
4. Calculate Hamiltonian = H [s candidate ] of s candidate after the change.
5. If H [s candidate ] is smaller than H [s i ], proceed as s i+1 = s candidate . This is called
accepted.
Otherwise, if e −β(H [s i+1 ]−H [s i ]) is smaller than the random number 0 < r < 1,
accept s candidate . If all the above conditions are not met, s i+1 = s i . (This is called
rejected.)
The last part (step 5) is also called the Metropolis test. β is the inverse temperature
in statistical mechanics, but in general calculations, βH may be redefined as H and
renormalized.
At this stage, how to update the state has not yet been specified, and it depends
on the system. As an example of the update, in the case of the Ising model, one can
try reversing the spin of one site. 25
5.3.2 Heatbath Method
In physics, what is called the heatbath method can also be derived from the
principle of fine balance. In the field of machine learning, it is also called the Gibbs
sampler. The heatbath method focuses on a single degree of freedom in the system,
divides the whole system into the single degree of freedom and the other degrees
(heatbath), and uses only the probability of existence of the single degree of freedom
in contact with the heatbath (irrespective of that extracted single degree of freedom),
and determines the next state of that degree of freedom.
Let us assume that the transition probability from state s i to state s j is
proportional to the existence probability of the state s j . That is, we take it as
P (s j |s i ) ∝ P eq (s j ). Including the normalization factor, we have
P (s j |s i ) =
P eq (s j )
k P eq (s k )
.
(5.73)
25 The HMC (Hamiltonian/Hybrid Monte Carlo) method can be regarded as one example of the
Metropolis method, although we will not introduce it in this book.
97
Note that the transition probability depends only on the difference of the energy.
In other words, if we change the state by some appropriate method and look at the
change in energy, we will know the transition probability. Since it is not necessary to
find the entire transition matrix (or the partition function), it is a versatile algorithm
that can be applied regardless of the number of states, if we do not question if it is
an optimal one.
The steps to execute the Metropolis method are summarized as follows:
1. First, prepare an appropriate state s 0 . Hereinafter, repeat i = 0, 1, 2, 3 · · · .
2. Calculate Hamiltonian (= H [s i ]) at s i .
3. Change the state s i to s candidate by some means.
4. Calculate Hamiltonian = H [s candidate ] of s candidate after the change.
5. If H [s candidate ] is smaller than H [s i ], proceed as s i+1 = s candidate . This is called
accepted.
Otherwise, if e −β(H [s i+1 ]−H [s i ]) is smaller than the random number 0 < r < 1,
accept s candidate . If all the above conditions are not met, s i+1 = s i . (This is called
rejected.)
The last part (step 5) is also called the Metropolis test. β is the inverse temperature
in statistical mechanics, but in general calculations, βH may be redefined as H and
renormalized.
At this stage, how to update the state has not yet been specified, and it depends
on the system. As an example of the update, in the case of the Ising model, one can
try reversing the spin of one site. 25
5.3.2 Heatbath Method
In physics, what is called the heatbath method can also be derived from the
principle of fine balance. In the field of machine learning, it is also called the Gibbs
sampler. The heatbath method focuses on a single degree of freedom in the system,
divides the whole system into the single degree of freedom and the other degrees
(heatbath), and uses only the probability of existence of the single degree of freedom
in contact with the heatbath (irrespective of that extracted single degree of freedom),
and determines the next state of that degree of freedom.
Let us assume that the transition probability from state s i to state s j is
proportional to the existence probability of the state s j . That is, we take it as
P (s j |s i ) ∝ P eq (s j ). Including the normalization factor, we have
P (s j |s i ) =
P eq (s j )
k P eq (s k )
.
(5.73)
25 The HMC (Hamiltonian/Hybrid Monte Carlo) method can be regarded as one example of the
Metropolis method, although we will not introduce it in this book.
