MCMC as a function with dynamic Metropolis