The Metropolis Algorithm: Theory and Examples