BBy Bot
Jun 09'24

Exercise

[math] \newcommand{\NA}{{\rm NA}} \newcommand{\mat}[1]{{\bf#1}} \newcommand{\exref}[1]{\ref{##1}} \newcommand{\secstoprocess}{\all} \newcommand{\NA}{{\rm NA}} \newcommand{\mathds}{\mathbb}[/math]

For Buffon's needle problem, Laplace[Notes 1] considered a grid with horizontal and vertical lines one unit apart. He

showed that the probability that a needle of length [math]L \leq 1[/math] crosses at least one line is

[[math]] p = \frac{4L - L^2}\pi\ . [[/math]]

To simulate this experiment we choose at random an angle [math]\theta[/math] between 0 and [math]\pi/2[/math] and independently two numbers [math]d_1[/math] and [math]d_2[/math] between 0 and [math]L/2[/math]. (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 [math]d_1 \leq (L/2)\sin\theta[/math] or [math]d_2 \leq (L/2)\cos\theta[/math]. We do this a large number of times and estimate [math]\pi[/math] as

[[math]] \bar \pi = \frac{4L - L^2}a\ , [[/math]]

where [math]a[/math] is the proportion of times that the needle crosses at least one line. Write a program to estimate [math]\pi[/math] by this method, run your program for 100, 1000, and 10,00 experiments, and compare your results with Buffon's method described in Exercise Exercise. (Take [math]L = 1[/math].)

Notes

  1. P. S. Laplace, Théorie Analytique des Probabilités (Paris: Courcier, 1812).