  We describe an efficient Monte Carlo algorithm using a random walk in energy
space to obtain a very accurate estimate of the density of states for classical
statistical models. The density of states is modified at each step when the
energy level is visited to produce a flat histogram. By carefully controlling
the modification factor, we allow the density of states to converge to the true
value very quickly, even for large systems. This algorithm is especially useful
for complex systems with a rough landscape since all possible energy levels are
visited with the same probability. In this paper, we apply our algorithm to
both 1st and 2nd order phase transitions to demonstrate its efficiency and
accuracy. We obtained direct simulational estimates for the density of states
for two-dimensional ten-state Potts models on lattices up to $200 \times 200 $
and Ising models on lattices up to $256 \times 256$. Applying this approach to
a 3D $\pm J$ spin glass model we estimate the internal energy and entropy at
zero temperature; and, using a two-dimensional random walk in energy and
order-parameter space, we obtain the (rough) canonical distribution and energy
landscape in order-parameter space. Preliminary data suggest that the glass
transition temperature is about 1.2 and that better estimates can be obtained
with more extensive application of the method.
