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:

    All that a city will ever allow you is an angle on it—an oblique, indirect sample of what it contains, or what passes through it; a point of view.
    Peter Conrad (b. 1948)

    Wise Draco comes, deep in the midnight roll
    Of black artillery; he comes, though late;
    In code corroborating Calvin’s creed
    And cynic tyrannies of honest kings;
    He comes, nor parlies; and the Town, redeemed,
    Gives thanks devout; nor, being thankful, heeds
    The grimy slur on the Republic’s faith implied,
    Which holds that Man is naturally good,
    And—more—is Nature’s Roman, never to be
    scourged.
    Herman Melville (1819–1891)