# Buffon's needle problem

(Redirected from Buffon's needle)
The a needle lies across a line, while the b needle does not.

In mathematics, Buffon's needle problem is a question first posed in the 18th century by Georges-Louis Leclerc, Comte de Buffon:[1]

Suppose we have a floor made of parallel strips of wood, each the same width, and we drop a needle onto the floor. What is the probability that the needle will lie across a line between two strips?

Buffon's needle was the earliest problem in geometric probability to be solved;[2] it can be solved using integral geometry. The solution for the sought probability p, in the case where the needle length is not greater than the width t of the strips, is

${\displaystyle p={\frac {2}{\pi }}\cdot {\frac {\ell }{t}}.}$

This can be used to design a Monte Carlo method for approximating the number π, although that was not the original motivation for de Buffon's question.[3]

## Solution

The problem in more mathematical terms is: Given a needle of length ${\displaystyle \ell }$ dropped on a plane ruled with parallel lines t units apart, what is the probability that the needle will lie across a line upon landing?

Let x be the distance from the center of the needle to the closest parallel line, and let θ be the acute angle between the needle and one of the parallel lines.

The uniform probability density function of x between 0 and t/2 is

${\displaystyle {\begin{cases}{\frac {2}{t}}&:\ 0\leq x\leq {\frac {t}{2}}\\0&:{\text{elsewhere.}}\end{cases}}}$

Here, x = 0 represents a needle that is centered directly on a line, and xt/2 represents a needle that is perfectly centered between two lines. The uniform PDF assumes the needle is equally likely to fall anywhere in this range, but could not fall outside of it.

The uniform probability density function of θ between 0 and π/2 is

${\displaystyle {\begin{cases}{\frac {2}{\pi }}&:\ 0\leq \theta \leq {\frac {\pi }{2}}\\0&:{\text{elsewhere.}}\end{cases}}}$

Here, θ = 0 radians represents a needle that is parallel to the marked lines, and θ = π/2 radians represents a needle that is perpendicular to the marked lines. Any angle within this range is assumed an equally likely outcome.

The two random variables, x and θ, are independent, so the joint probability density function is the product

${\displaystyle {\begin{cases}{\frac {4}{t\pi }}&:\ 0\leq x\leq {\frac {t}{2}},\ 0\leq \theta \leq {\frac {\pi }{2}}\\0&:{\text{elsewhere.}}\end{cases}}}$

The needle crosses a line if

${\displaystyle x\leq {\frac {\ell }{2}}\sin \theta .}$

Now there are two cases.

### Case 1: Short needle

Integrating the joint probability density function gives the probability that the needle will cross a line:

${\displaystyle P=\int _{\theta =0}^{\pi /2}\int _{x=0}^{(\ell /2)\sin \theta }{\frac {4}{t\pi }}\,dx\,d\theta ={\frac {2\ell }{t\pi }}.}$

### Case 2: Long needle

Suppose ${\displaystyle \ell >t}$. In this case, integrating the joint probability density function, we obtain:

${\displaystyle \int _{\theta =0}^{\pi /2}\int _{x=0}^{m(\theta )}{\frac {4}{t\pi }}\,dx\,d\theta ,}$ where ${\displaystyle m(\theta )}$ is the minimum between ${\displaystyle (\ell /2)\sin \theta }$ and ${\displaystyle t/2}$.

Thus, performing the above integration, we see that, when ${\displaystyle t<\ell }$, the probability that the needle will cross a line is

${\displaystyle {\frac {2\ell }{t\pi }}-{\frac {2}{t\pi }}\left\{{\sqrt {\ell ^{2}-t^{2}}}+t\sin ^{-1}\left({\frac {t}{\ell }}\right)\right\}+1}$

or

${\displaystyle {\frac {2}{\pi }}\cos ^{-1}{\frac {t}{\ell }}+{\frac {2}{\pi }}{\frac {\ell }{t}}\left\{1-{\sqrt {1-\left({\frac {t}{\ell }}\right)^{2}}}\right\}.}$

In the second expression, the first term represents the probability of the angle of the needle being such that it will always cross at least one line. The right term represents the probability that, the needle falls at an angle where its position matters, and it crosses the line.

Alternatively notice that whenever ${\displaystyle \theta }$ has a value such that ${\displaystyle \ell \sin \theta \leq t}$, that is, in the range ${\displaystyle 0\leq \theta \leq \sin ^{-1}(t/\ell )}$ the probability of crossing is the same as in the short needle case. However if ${\textstyle \ell \sin \theta >t}$, that is, ${\displaystyle \sin ^{-1}(t/\ell )<\theta \leq {\frac {\pi }{2}}}$ the probability is constant and is equal to 1.

${\displaystyle \left(\int _{\theta =0}^{\sin ^{-1}(t/\ell )}\int _{x=0}^{(\ell /2)\sin \theta }{\frac {4}{t\pi }}\right)+\left(\int _{\sin ^{-1}(t/\ell )}^{\pi /2}{\frac {2}{\pi }}\right)={\frac {2\ell }{t\pi }}-{\frac {2}{t\pi }}\left\{{\sqrt {\ell ^{2}-t^{2}}}+t\sin ^{-1}\left({\frac {t}{\ell }}\right)\right\}+1}$

## Using elementary calculus

The following solution for the "short needle" case, while equivalent to the one above, has a more visual flavor, and avoids iterated integrals.

We can calculate the probability ${\displaystyle P}$ as the product of 2 probabilities: ${\displaystyle P=P_{1}\cdot P_{2}}$, where ${\displaystyle P_{1}}$ is the probability that the center of the needle falls close enough to a line for the needle to possibly cross it, and ${\displaystyle P_{2}}$ is the probability that the needle actually crosses the line, given that the center is within reach.

Looking at the illustration in the above section, it is apparent that the needle can cross a line if the center of the needle is within ${\displaystyle \ell /2}$ units of either side of the strip. Adding ${\displaystyle {\frac {\ell }{2}}+{\frac {\ell }{2}}}$ from both sides and dividing by the whole width ${\displaystyle t}$, we obtain ${\displaystyle P_{1}={\frac {\ell }{t}}.}$

The red and blue needles are both centered at x. The red one falls within the gray area, contained by an angle of 2θ on each side, so it crosses the vertical line; the blue one does not. The proportion of the circle that is gray is what we integrate as the center x goes from 0 to 1

Now, we assume that the center is within reach of the edge of the strip, and calculate ${\displaystyle P_{2}}$. To simplify the calculation, we can assume that ${\displaystyle \ell =2}$.

Let x and θ be as in the illustration in this section. Placing a needle's center at x, the needle will cross the vertical axis if it falls within a range of 2θ radians, out of π radians of possible orientations. This represents the gray area to the left of x in the figure. For a fixed x, we can express θ as a function of x: ${\displaystyle \theta (x)=\cos ^{-1}(x)}$. Now we can let x move from 0 to 1, and integrate:

${\displaystyle P_{2}=\int _{0}^{1}{\frac {2\theta (x)}{\pi }}\,dx={\frac {2}{\pi }}\int _{0}^{1}\cos ^{-1}(x)\,dx={\frac {2}{\pi }}\cdot 1={\frac {2}{\pi }}.}$

Multiplying both results, we obtain ${\displaystyle P=P_{1}\cdot P_{2}={\frac {\ell }{t}}{\frac {2}{\pi }}={\frac {2\ell }{t\pi }}}$, as above.

There is an even more elegant and simple method of calculating the "short needle case". The end of the needle farthest away from any one of the two lines bordering its region must be located within a horizontal (perpendicular to the bordering lines) distance of ${\displaystyle l\cos \theta }$ (where ${\displaystyle \theta }$ is the angle between the needle and the horizontal) from this line in order for the needle to cross it. The farthest this end of the needle can move away from this line horizontally in its region is ${\displaystyle t}$. The probability that the farthest end of the needle is located no more than a distance ${\displaystyle l\cos \theta }$ away from the line (and thus that the needle crosses the line) out of the total distance ${\displaystyle t}$ it can move in its region for ${\displaystyle 0\leq \theta \leq \pi /2}$ is given by

${\displaystyle P={\frac {\int _{0}^{\pi /2}\ell \cos \theta \,d\theta }{\int _{0}^{\pi /2}t\,d\theta }}={\frac {\ell }{t}}{\frac {\int _{0}^{\frac {\pi }{2}}\cos \theta \,d\theta }{\int _{0}^{\pi /2}d\theta }}={\frac {\ell }{t}}{\frac {1}{\pi /2}}={\frac {2\ell }{t\pi }},}$ as above.

## Without integrals

The short-needle problem can also be solved without any integration, in a way that explains the formula for p from the geometric fact that a circle of diameter t will cross the distance t strips always (i.e. with probability 1) in exactly two spots. This solution was given by Joseph-Émile Barbier in 1860[4] and is also referred to as "Buffon's noodle".

## Estimating π

An experiment to find π. Matches with the length of 9 squares have been thrown 17 times between rows with the width of 9 squares. 11 of the matches have landed at random across the drawn lines marked by the green points.
(2·n)/(th) = (2·9·17)/(9·11) ≈ 3.1 ≈ π.
A Python 3 based simulation using Matplotlib to sketch Buffon's needle experiment with the parameters t = 5.0,  = 2.6. Observe the calculated value of π (y-axis) approaching 3.14 as the number of tosses (x-axis) approaches infinity.

In the first, simpler case above, the formula obtained for the probability ${\displaystyle P}$ can be rearranged to

${\displaystyle \pi ={\frac {2\ell }{tP}}.}$
Thus, if we conduct an experiment to estimate ${\displaystyle P}$, we will also have an estimate for π.

Suppose we drop n needles and find that h of those needles are crossing lines, so ${\displaystyle P}$ is approximated by the fraction ${\displaystyle h/n}$. This leads to the formula:

${\displaystyle \pi \approx {\frac {2\ell \cdot n}{th}}.}$

In 1901, Italian mathematician Mario Lazzarini performed Buffon's needle experiment. Tossing a needle 3408 times, he obtained the well-known approximation 355/113 for π, accurate to six decimal places.[5] Lazzarini's "experiment" is an example of confirmation bias, as it was set up to replicate the already well-known approximation of 355/113 (in fact, there is no better rational approximation with fewer than five digits in the numerator and denominator, see also Milü), yielding a more accurate "prediction" of π than would be expected from the number of trials, as follows: [6]

Lazzarini chose needles whose length was 5/6 of the width of the strips of wood. In this case, the probability that the needles will cross the lines is ${\textstyle {\frac {5}{3\pi }}}$. Thus if one were to drop n needles and get x crossings, one would estimate π as:

${\displaystyle \pi \approx {\frac {5}{3}}\cdot {\frac {n}{x}}}$
So if Lazzarini was aiming for the result 355/113, he needed n and x such that:
${\displaystyle {\frac {355}{113}}={\frac {5}{3}}\cdot {\frac {n}{x}}}$
or equivalently,
${\displaystyle x={\frac {113n}{213}}.}$
To do this, one should pick n as a multiple of 213, because then ${\textstyle {\frac {113n}{213}}}$ is an integer; one then drops n needles, and hopes for exactly ${\textstyle x={\frac {113n}{213}}}$ successes. If one drops 213 needles and happens to get 113 successes, then one can triumphantly report an estimate of π accurate to six decimal places. If not, one can just do 213 more trials and hope for a total of 226 successes; if not, just repeat as necessary. Lazzarini performed 3408 = 213 · 16 trials, making it seem likely that this is the strategy he used to obtain his "estimate."

The above description of strategy might even be considered charitable to Lazzarini. A statistical analysis of intermediate results he reported for fewer tosses leads to a very low probability of achieving such close agreement to the expected value all through the experiment. This makes it very possible that the "experiment" itself was never physically performed, but based on numbers concocted from imagination to match statistical expectations, but too well, as it turns out.[6]

Dutch science journalist Hans van Maanen argues, however, that Lazzarini's article was never meant to be taken too seriously as it would have been pretty obvious for the readers of the magazine (aimed at school teachers) that the apparatus that Lazzarini said to have built cannot possibly work as described.[7]

## Laplace's Extension (Short Needle Case)

Now consider the case where the plane contains two sets of parallel lines orthogonal to one another, creating a standard perpendicular grid. We aim to find the probability that the needle intersects at least one line on the grid. Let ${\displaystyle a,b}$ be the sides of the rectangle that contains the midpoint of the needle whose length is ${\displaystyle \ell }$. Since this is the short needle case, ${\displaystyle \ell . Let ${\displaystyle (x,y)}$ mark the coordinates of the needle's midpoint and let ${\displaystyle \varphi }$ mark the angle formed by the needle and the x-axis. Similar to the examples described above, we consider ${\displaystyle x,y,\varphi }$ to be independent uniform random variables over the ranges ${\displaystyle 0\leq x\leq a,\quad 0\leq y\leq b,\quad {\frac {-\pi }{2}}\leq \varphi \leq {\frac {\pi }{2}}}$.

To solve such a problem, we first compute the probability that the needle crosses no lines, and then we take its compliment. We compute this first probability by determining the volume of the domain where the needle crosses no lines and then divide that by the volume of all possibilities, ${\displaystyle V}$. We can easily see that ${\displaystyle V=\pi ab}$.

Now let ${\displaystyle V^{*}}$ be the volume of possibilities where the needle does not intersect any line. Developed by J.V. Uspensky,[8]

${\displaystyle V^{*}=\int _{\frac {-\pi }{2}}^{\frac {\pi }{2}}F(\varphi )d\varphi }$

where ${\displaystyle F(\varphi )}$ is the region where the needle does not intersect any line given an angle ${\displaystyle \varphi }$. To determine ${\displaystyle F(\varphi )}$, let's first look at the case for the horizontal edges of the bounding rectangle. The total side length is ${\displaystyle a}$ and the midpoint must not be within ${\displaystyle {\frac {l}{2}}\cos(\varphi )}$ of either endpoint of the edge. Thus, the total allowable length for no intersection is ${\displaystyle a-2({\frac {l}{2}}\cos(\varphi ))}$ or simply just ${\displaystyle a-l\cos(\varphi )}$. Equivalently, for the vertical edges with length ${\displaystyle b}$, we have ${\displaystyle b\pm l\sin(\varphi )}$. The ${\displaystyle \pm }$ accounts for the cases where ${\displaystyle \varphi }$ is positive or negative. Taking the positive case and then adding the absolute value signs in the final answer for generality, we get

${\displaystyle F(\varphi )=(a-l\cos(\varphi ))(b-l\sin(\varphi ))=ab-bl\cos(\varphi )-al|\sin(\varphi )|+{\frac {1}{2}}l^{2}|\sin(2\varphi )|}$.

Now we can compute the following integral:

${\displaystyle V^{*}=\int _{\frac {-\pi }{2}}^{\frac {\pi }{2}}F(\varphi )d\varphi =\pi ab-2bl-2al+l^{2}}$.

Thus, the probability that the needle does not intersect any line is

${\displaystyle {\frac {V^{*}}{V}}={\frac {\pi ab-2bl-2al+l^{2}}{\pi ab}}=1-{\frac {2l(a+b)-l^{2}}{\pi ab}}.}$

And finally, if we want to calculate the probability, ${\displaystyle p}$, that the needle does intersect at least one line, we need to subtract the above result from 1 to compute its compliment, yielding

${\displaystyle p={\frac {2l(a+b)-l^{2}}{\pi ab}}}$.

## Comparing Estimators of π

As mentioned above, Buffon's needle experiment can be used to estimate π. This fact holds for Laplace's extension too since π shows up in that answer as well. The following question then naturally arises and is discussed by E.F. Schuster in 1974[9]. Is Buffon's experiment or Laplace's a better estimator of the value of π? Since in Laplace's extension there are two sets of parallel lines, we compare ${\displaystyle N}$ drops when there is a grid (Laplace), and ${\displaystyle 2N}$ drops in the original Buffon's needle experiment.

Let ${\displaystyle A}$ be the event that the needle intersects a horizontal line (parallel to x-axis)

${\displaystyle x={\begin{cases}1&:{\text{intersection occurs}}\\0&:{\text{no intersection }}\end{cases}}}$

and let ${\displaystyle B}$ be the event that the needle intersects a vertical line (parallel to the y-axis)

${\displaystyle y={\begin{cases}1&:{\text{intersection occurs}}\\0&:{\text{no intersection }}\end{cases}}}$

For simplicity in the algebraic formulation ahead, let ${\displaystyle a=b=t=2l}$ such that the original result in Buffon's problem is ${\displaystyle P(A)=P(B)={\frac {1}{\pi }}}$. Furthermore, let ${\displaystyle N=100}$ drops.

Now let's examine ${\displaystyle P(AB)}$ for Laplace's result, i.e. the probability the needle intersects both a horizontal and a vertical line. We know that

${\displaystyle P(AB)=1-P(AB')-P(A'B)-P(A'B')}$.

From the above section, ${\displaystyle P(A'B')}$, or the probability that the needle intersects no lines is

${\displaystyle P(A'B')=1-{\frac {2l(a+b)-l^{2}}{\pi ab}}=1-{\frac {2l(4l)-l^{2}}{4l^{2}\pi }}=1-{\frac {7}{4\pi }}}$.

We can solve for ${\displaystyle P(A'B)}$ and ${\displaystyle P(AB')}$ using the following method:

${\displaystyle P(A)={\frac {1}{\pi }}=P(AB)+P(AB')}$
${\displaystyle P(B)={\frac {1}{\pi }}=P(AB)+P(A'B)}$.

Solving for ${\displaystyle P(AB')}$ and ${\displaystyle P(A'B)}$ and plugging that into the original definition for ${\displaystyle P(AB)}$ a few lines above, we get

${\displaystyle P(AB)=1-2{\big [}{\frac {1}{\pi }}-P(AB){\big ]}-(1-{\frac {7}{4\pi }})={\frac {1}{4\pi }}}$

Although not necessary to the problem, it is now possible to see that ${\displaystyle P(A'B)=P(AB')={\frac {3}{4\pi }}}$. With the values above, we are now able to determine which of these estimators is a better estimator for π. For the Laplace variant, let ${\displaystyle {\hat {p}}}$ be the estimator for the probability that there is a line intersection such that

${\displaystyle {\hat {p}}={\frac {1}{100}}\sum _{n=1}^{100}{\frac {x_{n}+y_{n}}{2}}}$.

We are interested in the variance of such an estimator to understand the usefulness or efficiency of it. To compute the variance of ${\displaystyle {\hat {p}}}$, we first compute ${\displaystyle {\text{Var}}(x_{n}+y_{n})}$ where

${\displaystyle {\text{Var}}(x_{n}+y_{n})={\text{Var}}(x_{n})+{\text{Var}}(y_{n})+2{\text{Cov}}(x_{n},y_{n})}$.

Solving for each part individually,

${\displaystyle {\text{Var}}(x_{n})={\text{Var}}(y_{n})=\sum _{i=1}^{2}p_{i}(x_{i}-\mathbb {E} [x_{i}])^{2}}$
${\displaystyle =P(x_{i}=1)(1-{\frac {1}{\pi }})^{2}+P(x_{i}=0)(0-{\frac {1}{\pi }})^{2}}$
${\displaystyle ={\frac {1}{\pi }}(1-{\frac {1}{\pi }})^{2}+(1-{\frac {1}{\pi }})(-{\frac {1}{\pi }})^{2}={\frac {1}{\pi }}(1-{\frac {1}{\pi }})}$.
${\displaystyle {\text{Cov}}(x_{n},y_{n})=\mathbb {E} (x_{n}y_{n})-\mathbb {E} (x_{n})\mathbb {E} (y_{n})}$

We know from the previous section that ${\displaystyle \mathbb {E} (x_{n}y_{n})=P(AB)={\frac {1}{4\pi }}}$ yielding

${\displaystyle {\text{Cov}}(x_{n},y_{n})={\frac {1}{4\pi }}-{\big (}{\frac {1}{\pi }}{\big )}{\big (}{\frac {1}{\pi }}{\big )}={\frac {\pi -4}{4\pi ^{2}}}<0}$

Thus,

${\displaystyle {\text{Var}}(x_{n}+y_{n})={\frac {1}{\pi }}(1-{\frac {1}{\pi }})+{\frac {1}{\pi }}(1-{\frac {1}{\pi }})+2({\frac {\pi -4}{4\pi ^{2}}})={\frac {5\pi -8}{2\pi ^{2}}}}$

Returning to the original problem of this section, the variance of estimator ${\displaystyle {\hat {p}}}$ is

${\displaystyle {\text{Var}}({\hat {p}})={\frac {1}{200^{2}}}(100)({\frac {5\pi -8}{2\pi ^{2}}})\approx .000976.}$

Now let's calculate the number of drops, ${\displaystyle M}$, needed to achieve the same variance as 100 drops over perpendicular lines. If ${\displaystyle M<200}$ then we can conclude that the setup with only parallel lines is more efficient than the case with perpendicular lines. Conversely if ${\displaystyle M}$ is equal to or more than 200, than Buffon's experiment is equally or less efficient, respectively. Let ${\displaystyle {\hat {q}}}$ be the estimator for Buffon's original experiment. Then,

${\displaystyle {\hat {q}}={\frac {1}{M}}\sum _{m=1}^{M}x_{m}}$
${\displaystyle {\text{Var}}({\hat {q}})={\frac {1}{M^{2}}}(M){\text{Var}}(x_{m})={\frac {1}{M}}{\frac {1}{\pi }}(1-{\frac {1}{\pi }})\approx {\frac {0.217}{M}}}$

Solving for M,

${\displaystyle {\frac {0.217}{M}}=.000976\implies M\approx 222.}$

Thus, it takes 222 drops with only parallel lines to have the same certainty as 100 drops in Laplace's case. This isn't actually surprising because of the observation that ${\displaystyle {\text{Cov}}(x_{n},y_{n})<0}$. Because ${\displaystyle x_{n},y_{n}}$ are negatively correlated random variables, they act to reduce the total variance in the estimator that is an average of the two of them. This method of variance reduction is know as the antithetic variates method.

## References

1. ^ Histoire de l'Acad. Roy. des. Sciences (1733), 43–45; Histoire naturelle, générale et particulière Supplément 4 (1777), p. 46.
2. ^ Seneta, Eugene; Parshall, Karen Hunger; Jongmans, François (2001). "Nineteenth-Century Developments in Geometric Probability: J. J. Sylvester, M. W. Crofton, J.-É. Barbier, and J. Bertrand". Archive for History of Exact Sciences. 55 (6): 501–524. doi:10.1007/s004070100038. ISSN 0003-9519. JSTOR 41134124. S2CID 124429237.
3. ^ Behrends, Ehrhard. "Buffon: Hat er Stöckchen geworfen oder hat er nicht?" (PDF). Retrieved 14 March 2015.
4. ^ Aigner, Martin; Ziegler, Günter M. (2013). Proofs from THE BOOK (2nd ed.). Springer Science & Business Media. pp. 189–192.
5. ^ Lazzarini, M. (1901). "Un'applicazione del calcolo della probabilità alla ricerca sperimentale di un valore approssimato di π" [An Application of Probability Theory to Experimental Research of an Approximation of π]. Periodico di Matematica per l'Insegnamento Secondario (in Italian). 4: 140–143.
6. ^ a b Lee Badger, 'Lazzarini's Lucky Approximation of π', Mathematics Magazine 67, 1994, 83–91.
7. ^ Hans van Maanen, 'Het stokje van Lazzarini' (Lazzarini's stick), "Skepter" 31.3, 2018.
8. ^ J.V. Uspensky, 'Introduction to Mathematical Probability', 1937, 255.
9. ^ E. F. Schuster, Buffon's Needle Experiment, The American Mathematical Monthly, 1974, 29-29.