Computational Methods and Algorithms An Extension of theMetropolis Algorithm