Ron Mak @ Apropos Logic
Publications and books by Ronald Mak

Java Number Cruncher

Program 14-3

Monte Carlo and Buffon's Needles

This applet 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.