# Monte Carlo Metropolis method - trial step algorithm

I'm working on a Magnetization simulation and writing an algorithm using the metropolis method.

I am using a change in energy and a Boltzmann distribution, but, my question is about the trial step. Should the trial position of the magnetization be completely random or should it be a random differential added onto the position of the old magnetization?

My energy basically depends on an angle, so, my range is 0 to Pi, and to get anything near a 50% rejection I'm adding or subtracting approximately pi over 4 from each step - which is far too large. If I reduce it to something reasonably small, then the difference in energy between the old and new energy probability is about 0.999 to 1.001. (here I create a random, small angle and add or subtract it from the current angle of the magnetization vector.)

## migrated from physics.stackexchange.comFeb 2 '16 at 2:50

This question came from our site for active researchers, academics and students of physics.

• An important question to ask yourself is "Do you want to map the whole space, or to converge on a single answer?" And if you want one (or a small number of) answer(s) you have consider how scared you are of ending in sub-optimal local extrema and if you want any annealing. – dmckee Feb 2 '16 at 0:58
• My intent is to scale up to a thousand particles and look at average magnetization in different fields. So, since I am primarily interested in the average, I think I want to map the whole space. But I still want something that has meaning, jumping around at these large angles is scary just because I'm not sure I'm getting any good information out of an average. – Joseph Feb 2 '16 at 1:01
• So parameterize the step size and anneal: start large and slowly squeeze it down. Gives you a chance to learn if you've missed a golden spot but still end with a well defined answer. You can also average over multiple walkers to improve the odds of a good overall map. There are lots of variations. – dmckee Feb 2 '16 at 1:04
• Ok, I guess I've kind of done that - but my understanding is that if the method is to have meaning you should operate in a 30-70% rejection range, and I am working around 10% rejection. – Joseph Feb 2 '16 at 1:07
• i guess my questions are really more about the computational side then the physics side so if you want to migrate it - that would be fine – Joseph Feb 2 '16 at 1:51

What I mean is that you calculate the rate of rejection $\frac{n_{rejected}}{n_{total}}$, compare it with the goal and update your trial size to, let's say, something like $\pm10\%$ of it $$\delta\theta_{new}=\delta\theta\pm0.1\delta\theta$$
Notice that if the trial size is larger you'll end up with larger $e^{\Delta U}$ meaning more rejection so check the $\pm$ sign wisely depending on the rate of rejection. Also verify that $n_{total}$ is only considered with entries recorded since the last update of $\delta\theta$. This stuff should converge to a solution exploring a useful portion of the phase space and avoiding very low probable region at lower temperatures.