Dec 132017

Turbo Pascal source for a simulation of the classic Buffon Needle experiment that illustrates a statistical method for determining the value of Pi. Documentation included. | |||
---|---|---|---|

File Name | File Size | Zip Size | Zip Type |

BUFFON.DOC | 2392 | 1080 | deflated |

BUFFON.EXE | 10848 | 7178 | deflated |

BUFFON.PAS | 2964 | 1058 | deflated |

# Download File BUFFON.ZIP Here

## Contents of the BUFFON.DOC file

Explanation of the theory behind "Buffon's Needle Experiment".

In Buffon's experiment, a needle of length L is dropped

onto a plane ruled by a series of parallel lines separated

by a distance D. This could be a plank floor, for example.

If the experiment is conducted repeatedly, and the position

of the needle is indeed random after each drop, we can

determine a probability of the needle touching or intersecting

a line. This probability P would be the number of intercepts,

NI, divided by the number of trials, NT.

To simulate this test in software, we need to randomly

assign a position on the 'floor' for each trial. This has

been done by specifying the perpendicular distance of the

midpoint of the needle, M, relative to a line, and an angle,

THETA, that represents the direction the needle is pointing.

The sample space for this model can be reduced or simplified by

noting that the distance between only two lines need be

considered, as all other lines are merely duplicates of this

situation. And, since the random position is symmetric, only

half the distance between two lines needs to be modelled.

Thus, if M represents the midpoint of a needle, and A

is the distance from M to the line, the angle THETA can be

used to calculate the vertical projection of the needle over

the line. This distance is (L/2)*sin(THETA). If this distance

is less than A, then the needle indeed crosses the line.

In the software model, position A is chosen randomly from

0 < A < (D/2), in one-half a plank space. THETA is chosen

randomly from 0 < THETA < Pi, a half circle, because the

remainder of the circle is a duplicate situation (needle is

merely reversed). The vertical projection is calculated, and

if this distance is less than A, NI is incremented. After

NT trials, the probability P is NI/NT.

So how does this experiment come up with an approximation

for Pi?? It can be shown [but not here 😉 ], that the

theoretical solution to the needle problem is:

P = (2*L)/(Pi*D)

In the simulation we determine P, and L and D are specified,

thus we can calculate a value for Pi as:

Pi = (2*L)/(P*D)

Using a relatively large number of trials, say 10,000, and

relying on the somewhat suspect randomness of the 'random()'

statement in code, approximations for Pi withing 1% are common.

In Buffon's experiment, a needle of length L is dropped

onto a plane ruled by a series of parallel lines separated

by a distance D. This could be a plank floor, for example.

If the experiment is conducted repeatedly, and the position

of the needle is indeed random after each drop, we can

determine a probability of the needle touching or intersecting

a line. This probability P would be the number of intercepts,

NI, divided by the number of trials, NT.

To simulate this test in software, we need to randomly

assign a position on the 'floor' for each trial. This has

been done by specifying the perpendicular distance of the

midpoint of the needle, M, relative to a line, and an angle,

THETA, that represents the direction the needle is pointing.

The sample space for this model can be reduced or simplified by

noting that the distance between only two lines need be

considered, as all other lines are merely duplicates of this

situation. And, since the random position is symmetric, only

half the distance between two lines needs to be modelled.

Thus, if M represents the midpoint of a needle, and A

is the distance from M to the line, the angle THETA can be

used to calculate the vertical projection of the needle over

the line. This distance is (L/2)*sin(THETA). If this distance

is less than A, then the needle indeed crosses the line.

In the software model, position A is chosen randomly from

0 < A < (D/2), in one-half a plank space. THETA is chosen

randomly from 0 < THETA < Pi, a half circle, because the

remainder of the circle is a duplicate situation (needle is

merely reversed). The vertical projection is calculated, and

if this distance is less than A, NI is incremented. After

NT trials, the probability P is NI/NT.

So how does this experiment come up with an approximation

for Pi?? It can be shown [but not here 😉 ], that the

theoretical solution to the needle problem is:

P = (2*L)/(Pi*D)

In the simulation we determine P, and L and D are specified,

thus we can calculate a value for Pi as:

Pi = (2*L)/(P*D)

Using a relatively large number of trials, say 10,000, and

relying on the somewhat suspect randomness of the 'random()'

statement in code, approximations for Pi withing 1% are common.

December 13, 2017
Add comments