M function

The Metropolis Algorithm