Dropping a Needle for Pi

  • Hard
  • Probability puzzles
  • Tests: Getting a constant out of a random experiment

The puzzle

A floor is ruled with parallel lines a fixed distance apart. A needle exactly as long as that spacing is dropped at random.

What is the probability it crosses a line? And how would you use that to estimate pi?

Stuck?

One at a time, smallest first. Open only as many as you need — the whole point of the puzzle is the part you work out yourself.

Hint 1

Two things are random: where the needle's centre falls between the lines, and what angle it lands at.

Hint 2

For a given angle, the needle crosses if its centre is within half its projected length of a line.

Show the answer Hide the answer

2/pi, about 0.6366. So pi is roughly twice the number of drops divided by the number of crossings.

How to get there

Let the spacing and the needle length both be 1. The needle's angle to the lines is uniform, and for an angle t its vertical extent is sin(t). It crosses a line when its centre lies within sin(t)/2 of one, which has probability sin(t).

Averaging sin(t) over all angles from 0 to pi/2 gives 2/pi = 0.6366. So about 64 drops in 100 cross a line.

Rearranged, pi = 2 × drops / crossings. It works, and it is a terrible way to compute pi: the error falls as the square root of the number of drops, so getting three decimal places needs millions of throws. Its real importance is as the first problem in geometric probability, and as the ancestor of every Monte Carlo method since.

The technique worth keeping

When the randomness has two independent parts, fix one and average over the other. Conditioning on the angle turns a two-dimensional problem into a one-dimensional average, which is the standard route through geometric probability.