Search code examples
numpypymcmcmcrandom-walk

How to decide the step size when using Metropolis–Hastings algorithm


I have a simple question regarding to Metropolis–Hastings algorithm. Suppose the distribution only has one variable x and the value range of x is s=[-2^31,2^31].

In the sampling process, I need to propose a new value of x and then decide whether to accept it.

x_{t+1} =x_t+\epsilon 

If I want to implement it by myself, how to decide the value of \epsilon.

The basic solution is to pick a value from Uniform[-2^31,2^31] and set it to \epsilon. What if the value range is unbounded like [-inf, inf]?

How does the current MCMC library (e.g. pymc) solve that problem?


Solution

  • The best approach is to code a self-tuning algorithm that starts with an arbitrary variance for the step size variance, and tune this variance as the algorithm progresses. You are shooting for an acceptance rate of 25-50% for the Metropolis algorithm.