I'm trying to use Metropolis-Hastings to sample from a distribution that's very close to
and I'm finding that the method is undersampling near the origin, where there's a kink in the distribution function. I've attached an example figure. Is there a smoothness requirement to Metropolis-Hastings that isn't discussed that often? If so, is there a good workaround for this or alternative algorithm?
Edit: Here is a minimal working example, along with the output.
def exp_func(x, ell): return np.exp(-np.abs(x)/ell) ell = 2. sigma = 1. n_samples = 5000 sequence = np.zeros(n_samples) theta_t = np.random.random() idx = 0 while idx < n_samples: theta_star = np.random.normal(loc=theta_t, scale=sigma) alpha = min(exp_func(theta_star, ell)/exp_func(theta_t, ell), 1.) u = np.random.random() if u < alpha: theta_t = theta_star sequence[idx] = theta_star idx += 1
and what it produces: