Each
state of the system occurs with a specific probability. If we want to perform a simulation
of a system governed by a Hamiltonian in the canonical ensemble (constant temperature) we
need to devise a method to generate states that follow the Boltzmann distribution. This is
much like the generation of random numbers. For these we required that they follow the uniform
distributionTermsUniformDistribution@terms. Here the distribution is non-uniform and
has a non-trivial form.We are then required in a simulation to generate states or
configurations which follow a distribution other than the uniform. To pave the way to the
Monte Carlo method, let us see how we can generate a distribution using uniformly
distributed random numbers. Let

be the distribution that we want to generate. G(x) is some function in the open
interval (0,1). We obtain the distribution by devising an acceptance/rejection mechanism
based upon uniformly distributed random numbers. For this we draw a random number from a
uniform distribution. We rescale this number such that the number is in the interval over
which G is defined. Let t=G(x), where x is the number from the uniform distribution.
Earlier in this chapter we considered the occurrence for a run down or a run up in a
sequence of random numbers. We use a similar concept to accept or reject a drawn number x
to be a sample from the distribution f. Generate k numbers from a uniform distribution
where k is determined from the condition

If k is even reject x and start with a new x. If k is odd, we have a sample from the
desired distribution. Using this method it is easy to generate for example random numbers
that are distributed with a maxwell distribution or any other distribution.