Custom step for Metropolis-Hastings


I have a Potts model with spins s_i \in \{1, …, q\}:

P(s_1, ..., s_n) \sim \exp(\sum_i h_i(s_i) + \sum_{i < j} J_{ij}(s_i, s_j)),

where P denotes the probability of finding the configuration (s_1, ... s_n). I am given fixed values for h_i(s_i) for each s_i and J_{ij}(s_i, s_j) for each pair (s_i, s_j) (so I am not doing Bayesian inference to learn s_i or J_{ij}).

For convenience, call H(s_1, ..., s_n) = -\sum_i h_i(s_i) - \sum_{i < j} J_{ij}(s_i, s_j), so P(s_1, ..., s_n) \sim \exp (- H(s_1, ..., s_n)).

What I would like to do

Sample from distribution P using a custom step for Metropolis-Hastings MC. How can I use my own custom step?


In a previous post, it was suggested that I use:


because I am not trying to infer anything. This solves the first part of my problem (sample from a distribution). I would like help with the second part of my problem (I want to use my own Metropolis-Hastings step).

I would like to propose steps as follows:

  1. Given a configuration S = (s_1, ..., s_n), randomly pick a position i \in \{1, ..., n\}.
  2. Randomly choose s_i \in \{1, ..., q\} with uniform probability, call it j. Now define the proposed configuration S' = (s_1, ..., j, ..., s_n) where j is in the i-th position.
  3. Compute e^{H(S') - H(S)} and use it as the acceptance probability.
  4. Do accept/reject step as normal (i.e., choosing a random number).
  5. Repeat steps 1 - 4, starting from S' if accepted or S if rejected.