simple metropolis algorithm implementation