Metropolis sampler and supporting functions for estimating