Grinstead-Snell-Probability · Problem 7

Continuous Probability Densities

Mathematics · buffons-needle

Problem

For Buffon's needle problem, Laplace considered a grid with horizontal and vertical lines one unit apart. He showed that the probability that a needle of length L≤1L \leq 1 crosses at least one line is p=4L−L2π.p = \frac{4L - L^2}{\pi}. To simulate this experiment we choose at random an angle θ\theta between 0 and π/2\pi/2 and independently two numbers d1d_1 and d2d_2 between 0 and L/2L/2. (The two numbers represent the distance from the center of the needle to the nearest horizontal and vertical line.) The needle crosses a line if either d1≤(L/2)sin⁡θd_1 \leq (L/2)\sin\theta or d2≤(L/2)cos⁡θd_2 \leq (L/2)\cos\theta. We do this a large number of times and estimate π\pi as πˉ=4L−L2a,\bar{\pi} = \frac{4L - L^2}{a}, where aa is the proportion of times that the needle crosses at least one line. Write a program to estimate π\pi by this method, run your program for 100, 1000, and 10,000 experiments, and compare your results with Buffon's method described in Exercise 6. (Take L=1L = 1.)

Browse the problem library