Monte Carlo sampling of any system may be analyzed in terms of an associated
glass model -- a variant of the Random Energy Model -- with, whenever there is
a sign problem, complex fields. This model has three types of phases (liquid,
frozen and `chaotic'), as is characteristic of glass models with complex
parameters. Only the liquid one yields the correct answers for the original
problem, and the task is to design the simulation to stay inside it. The
statistical convergence of the sampling to the correct expectation values may
be studied in these terms, yielding a general lower bound for the computer time
as a function of the free energy difference between the true system, and a
reference one. In this way, importance-sampling strategies may be optimized