Example M-2 - Buffon's Needle
Problem Statement:
More than 200 years before Metropolis coined the name "Monte Carlo" method, George Louis Leclerc, Comte de Buffon, proposed the following problem.
"If a needle of length l is dropped at random on the middle of a horizontal surface ruled with parallel lines a distance d > l apart, what is the probability that the needle will cross one of the lines?"
Buffon
asked what was the probability that the needle would fall across one of the lines. That will
occur only if A <lsin(q).
In this case, the distance from the end of the needle to the horizontal line (denoted as "A") is randomly distributed [0, d). The angle at which the needle falls (denoted as theta, q) is also randomly distributed [0, 180).
Even though this probability can be easily obtained, it is interesting to note that the great mathematician Laplace perceived an amusing approximation for pi, p. Laplace argued that if Buffon’s experiment is performed with the needle being dropped N times, with M hits, then pi could be approximated by (2*N/M).
This example project attempts to approximate this value.
RENO Solution:
Define two Constants to describe the distance between the two horizontal lines (d) and the length of the needle (l).

Define two Random Variables to describe the distance from the end of the needle to the horizontal line (A) and the angle at which the needle falls (Theta), as shown next.


Define an Equation Variable to determine the span of the needle based on the length of the needle and the angle at which it falls (lsin(q)). If this is greater than A, then the needle crossed the horizontal line. SIN and RADIANS are pre-defined functions in RENO that can be typed into equations or inserted via the Function Wizard.

Construct the flowchart as follows:

Step 1: Use a Block to obtain the distance from the end of the needle to the horizontal line (A), based on the Random Variable.

Step 2: Use a Conditional Block to determine whether the needle crossed the horizontal line. If the span of the needle (determined by the Equation Variable called "Hit") is greater than or equal to the distance that was passed from the preceding Block (A), then the needle crossed the horizontal line and a 1 is passed to the TRUE path. A FALSE path is not required for this example.

Step 3: Use a Result Storage construct to store a sum of the number of times that the needle crossed the horizontal line (i.e. M in Laplace’s equation to approximate p).
Step 4: Use a Block to enter Laplace’s equation to approximate p. In this equation, the reserved keyword IN represents the value of M passed from the previous construct and the reserved keyword SIMS_TOTAL represents the total number of simulations (i.e. N in Laplace’s equation).

Step 5: Use another Result Storage construct to store the final result.
Specify to perform 1,000 simulations and vary the seed from 1 to 10 with increments of 1, as shown next. This will result in 10 runs of 1,000 simulations each, using a different set of randomly generated numbers for each run to give us a feel for the variation in the results.


The results are displayed in the Simulation Results Explorer as shown next.

The flowchart displays the last value of p, corresponding to seed 10.

A RENO project with the solution for this example (called "Buffon's Needle.rnp") is shipped with the software and stored in the Examples\Misc Fun folder in the application directory (e.g. C:\Program Files\ReliaSoft\RENO\Examples\Misc Fun\Buffon's Needle.rnp).


