Properly implement Monte Carlo sampling acoording to theory.