Wang and Landau Algorithm - Sample Code

Sample Code

The following is a sample code of the Wang–Landau algorithm in Python, considering that the proposal is such that

The code considers a "system" which is the underlying system being studied.


currentEnergy = system.randomConfiguration # a random initial configuration while (f > epsilon): system.proposeConfiguration # a proposed configuration is proposed proposedEnergy = system.proposedEnergy # the energy of the proposed configuration computed if (random < exp(entropy-entropy)): # if accepted, update the energy and the system: currentEnergy = proposedEnergy system.acceptProposedConfiguration else: # if rejected system.rejectProposedConfiguration H += 1 entropy += f if (isFlat(H)): # isFlat tests whether the histogram is flat (e.g. 95% flatness) H = 0 f *= 0.5 # refine the f parameter

Read more about this topic:  Wang And Landau Algorithm

Famous quotes containing the words sample and/or code:

    As a rule they will refuse even to sample a foreign dish, they regard such things as garlic and olive oil with disgust, life is unliveable to them unless they have tea and puddings.
    George Orwell (1903–1950)

    Faultless honesty is a sine qua non of business life. Not alone the honesty according to the moral code and the Bible. When I speak of honesty I refer to the small, hidden, evasive meannesses of our natures. I speak of the honesty of ourselves to ourselves.
    Alice Foote MacDougall (1867–1945)