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:

    The present war having so long cut off all communication with Great-Britain, we are not able to make a fair estimate of the state of science in that country. The spirit in which she wages war is the only sample before our eyes, and that does not seem the legitimate offspring either of science or of civilization.
    Thomas Jefferson (1743–1826)

    Many people will say to working mothers, in effect, “I don’t think you can have it all.” The phrase for “have it all” is code for “have your cake and eat it too.” What these people really mean is that achievement in the workplace has always come at a price—usually a significant personal price; conversely, women who stayed home with their children were seen as having sacrificed a great deal of their own ambition for their families.
    Anne C. Weisberg (20th century)