Course: Advanced sampling techniques
Course: Advanced sampling techniques
Course: Advanced sampling techniques
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Simulation of Biomolecules – p. 4<br />
Monte Carlo: The Idea<br />
⇒<br />
π<br />
#darts hitting shaded area<br />
#darts hitting inside square = 4 r2<br />
r 2 = π 4<br />
π = 4<br />
#darts hitting shaded area<br />
#darts hitting inside square<br />
• If you actually do this experiment, you’ll soon realize that it takes a<br />
very large number of throws to get a decent value of π, well over<br />
1 000.<br />
• To make things easy on ourselves, nowadays we can use<br />
computers and generate random numbers.<br />
• If we say our circle’s radius is 1.0, for each throw we can generate<br />
two random numbers between 0 and 1 for the x and y coordinate,<br />
which we can then use to calculate the distance from the origin.<br />
• If this distance is less than or equal to 1.0, it is within the shaded<br />
area and counts as a hit.