9. Buffon's needle problem
- Buffon's needle problem is a classic question, see for details
in Wikipedia
or
in WolframMathWorld. We
will generalize this question. Take a sufficiently large sheet
of paper that has parallel lines with unit distances from each
other. Drop a needle of length \(L\) randomly onto the
paper. Let \(X\) be the number of lines touched by the
needle. Write out the values of the frequency function of \(X\)
based on the \(N\) experiments at
\(0, 1, 2, \dots,\lfloor L \rfloor + 1\).
- The command line input of the program is a
positive integer number \(N\) and a positive real
number \(L\).
- The output is
- a sequence of \(\lfloor L\rfloor+2\) integer
numbers,
- the histogram belonging to this sequence, and
- the value of \(2L/a\), where \(a\) is the relative
frequency of those cases when exactly one line is
crossed.
- We remark that if \(L<1\), then the probability of
line-crossing is \(2L/\pi\), so the relative frequency of
the line-crossings approximates this value.
- Simulation can be simplified because of symmetry reasons in
several ways. For example, the angle between the needle and the
lines can be considered a uniformly distributed variable on the
interval \([0,\pi/2]\). Similarly, the distance of its center
from the nearest line is uniformly distributed on
\([0,0.5]\). One may calculate by supposing that the "left" end
point of the needle is uniformly distributed on \([0,1]\), and
so on.
- Those who love challenges may try to calculate the
probabilities for a particular \(L\) (e.g. \(L = 2\) or \(L =
5\)) comparing the results with the experimental values. This
isn't a compulsory part of this exercise!