14-3 Monte Carlo and Buffon’s Needles

This program demonstrates a Monte Carlo algorithm, Button’s needles. Needles of length 1 are dropped randomly onto a sheet of paper ruled with parallel lines 1 unit apart. The ratio of the number of needles that cross a line to the total number of needles approaches 2/pi, from which we can compute the value of pi.

To run the demo:

  1. Press the Run button to animate the algorithm.
  2. Press the Pause button to pause the algorithm.
  3. Press the Reset button to clear.

The original Java Applets do not run in modern browsers, but you can download the Java code and run it locally on your desktop. Check back for JavaScript and Python versions - coming soon!


Download Demos in Java