▁of ▁the ▁system . ▁ ▁Hence , ▁we ▁can ▁use ▁a ▁simple ▁harm onic ▁oscill ator ▁potential ▁to ▁test ▁the ▁accuracy ▁of ▁Wang – Land au ▁algorithm ▁because ▁we ▁know ▁already ▁the ▁analyt ic ▁form ▁of ▁the ▁density ▁of ▁states . ▁Therefore , ▁we ▁compare ▁the ▁estimated ▁density ▁of ▁states ▁ ▁obtained ▁by ▁the ▁Wang – Land au ▁algorithm ▁with ▁. ▁ ▁Sample ▁code ▁ ▁The ▁following ▁is ▁a ▁sample ▁code ▁of ▁the ▁Wang – Land au ▁algorithm ▁in ▁Python , ▁where ▁we ▁assume ▁that ▁a ▁symmetric ▁proposal ▁distribution ▁g ▁is ▁used : ▁ ▁The ▁code ▁cons iders ▁a ▁" system " ▁which ▁is ▁the ▁underlying ▁system ▁being ▁studied . ▁ ▁current E ner gy ▁= ▁system . random Configuration () ▁ ▁# ▁A ▁random ▁initial ▁configuration ▁ ▁while ▁( f ▁> ▁e psilon ): ▁▁▁▁ ▁system . pro pose Configuration () ▁ ▁# ▁A ▁proposed ▁configuration ▁is ▁proposed ▁▁▁▁ ▁proposed E ner gy ▁= ▁system . pro posed E ner gy () ▁ ▁# ▁The ▁energy ▁of ▁the ▁proposed ▁configuration ▁computed ▁▁▁▁▁ ▁if ▁( random () ▁< ▁exp ( ent ropy [ current E ner gy ] - ent ropy [ pro posed E ner gy ])) : ▁▁▁▁▁▁▁▁ ▁# ▁If ▁accepted , ▁update ▁the ▁energy ▁and ▁the ▁system : ▁▁▁▁▁▁▁▁ ▁current E ner gy ▁= ▁proposed E ner gy ▁▁▁▁▁▁▁▁ ▁system . accept Pro posed Configuration () ▁▁▁▁ ▁else : ▁▁▁▁▁▁▁▁ ▁# ▁If ▁rejected ▁▁▁▁▁▁▁▁ ▁system . re ject Pro posed Configuration () ▁▁▁▁▁ ▁H [ current E ner gy ]