[Temporary Example]
Buffon's
Needle
by Michael
J. Hurben
|
Source
Code: buff.java
"Buffon's Needle refers to a simple Monte Carlo method
for the estimation of the value of pi, 3.14159265... The idea
is very simple. Suppose you have a tabletop with a number of
parallel lines drawn on it, which are equally spaced (say the
spacing is 1 inch, for example). Suppose you also have a pin
or needle, which is also an inch long. If you drop the needle
on the table, you will find that one of two things happens:
(1) The needle crosses or touches one of the lines, or (2) the
needle crosses no lines. The idea now is to keep dropping this
needle over and over on the table, and to record the statistics.
Namely, we want to keep track of both the total number of times
that the needle is randomly dropped on the table (call this
N), and the number of times that it crosses a line (call this
C). If you keep dropping the needle, eventually you will find
that the number 2N/C approaches the value of pi! " continue
to M.
Hurbens Buffon's Needle page.
Each throw of a needle is an "event" in this simulation.
By event we mean that a single and complete process is simulated
and that it involves some degree of randomness and variation each
time. As the number of such events increases, the statistical error
on the calculation of a property of interest gradually becomes smaller
and smaller.
Another example of an event simulation would be a particle collision
program in which only after many collisions are simulated does the
calculation of, say, a reaction cross-section, become statistically
significant.
Most recent update: Nov. 9, 2005
|