# Why is the DOS from Wang-Landau's algoritm non-flat?

## Main Question or Discussion Point

Hi,

I'm trying to understand(implement) Wang-Landau's algorithm to calculate the DOS. There are zillions of seemingly identical descriptions on the net, which I thought are straightforward to type into a machine - but when reading the papers(codes) I don't get the main point, i.e. for me it seems as if the procedure should not generate anything else than just a flat DOS independent of the model under consideration.

If I understand correctly, then, at level 'l', and independent of acceptance or rejection, after each update attempt, the algorithm will increment both, the histogram h(E) by 1 and the entropy ln(g(E)) by ln(f)_l, at identical E, where E is either the accepted (new) energy or the old energy (after rejection) ... until h(E) is 'sufficiently' flat. Then one nullifies h(E), sets ln(f)_{l+1} = ln(f)_l/2, and starts the preceding all over again ... until ln(f)_l is 'sufficiently' close to zero. (There is a proper way of how to reject/accept, but I don't see how that is of relevance for my problem.)

So, if h(E)_l is the number of entries in each bin of the histogram at level 'l', then
ln(g(E))_l = h(E)_1*ln(f) + h(E)_2*ln(2)/2 + ... + h(E)_l*ln(f)/l
and since the stopping criterion at each level k is that h(E)_k is flat i.e. independent of E, so must be ln(g(E))_l.
In turn the DOS g(E) will be 'as flat as the histogram'.

What I am getting wrong here?

wbwb

Related Atomic and Condensed Matter News on Phys.org
Ok., I got it.
Maybe I should have thought about the algorithm a little more by myself, and not so much looked at some of the codes one can find on the net. (By now I think some of them are just plain wrong.)
I know, it is bad style to answer your own questions ... but anyway, if someone shows up here having similar issues:

The 'flatness' criterion in the Wang-Landau algorithm means something totally different then a 'function h(E)' which has zero slope to some relative numerical error - even if that error is never strictly set to '0'. That was my complete misunderstanding of the method. Actually one can convince oneself by playing Gedanken-experiments with toy models, that in some steady state of the code at level 'l' the histogram must not be 'roughly' constant as a function of 'E'. In fact, forcing such a situation will most likely put you in rare configurations (if at all) in which the DOS will most likely be wrong.

The way, in which the algorithm (i.m.h.o.) is meant to work implies that 'flatness' simply means 'sufficient statistics' for the histogram. This is a rather vague criterion. E.g. one could check this by testing how well the law of large numbers is satisfied separately for each entry of the histogram at each energy 'E', but probably there are many more ways to do that.

In conclusion, it this wording of the histogram being 'flat' which can be really confusing to newbies of the method: it does not mean flatness as a function of 'E', but rather when one considers h(E,ts), where 'ts' is some measure of the simulation time, then these should be more or less flat as functions of 'ts' for each 'E'.

wbwb

Last edited:
Not sure if that helps, but I have the feeling you are missing this point: In WL sampling you have two histograms: d(E) keeps track of the density of states in the respective energies. Then, there is a second histogram c(E) which counts how often the respective energies have been visited during the sampling run. If d(E) roughly represents the real density of states, all bins are, on average, visited equally often. Hence, the counting histogram c(E) becomes flat. Conversely, if c(E) becomes flat, you assume that your estimate d(E) is somewhat good/acceptable.

Bottom line: There are two histograms that are being tracked: The estimate for the density of states and the visit counts. It is the visit counts that are requested to become flat for the algorithm (or an iteration of it) to terminate, not the density of states. The criterion you suggested, looking after d(E) to become effectively stationary, should also work. But it sounds a bit harder to quantify.