Matthew Dennison

Buffon's needle

Imagine a floor made of parallel floorboards all of width L. If we drop a needle of length l at some random position on the floor, what is the likelyhood that it will land the division between two boards? This question was first posed by Georges-Louis Leclerc, Comte de Buffon. Buffon was interested in this as a problem in geometric probability, but it can also be used to estimate π.

  • Take a number of boards of width L and lay them parallel to each other.
  • Drop needles of length l<L randomly on the surface: niter.
  • Count the number that lie across the division between two boards: nover.
  • The probability P is then given by: P = n over/niter.
  • The probability is also given by: P=2l/Lπ.
  • π can be calculated as: π = 2l/LP.

  • The needles are dropped in batches of n_trial, and the estimate of π and its associated statistical error (given as the 95% confidence inteval) is given in the plot on the left. Try varying the ratio of the needle length to the board separation, and see how the error and success rate vary after a certain number of steps for different ratios.



    π against number of MC iterations

    Zoom: click and drag, Restore: double click


    Input

    Statistics

    Iterations:
    π = +/-