Home : Map : Chapter 1 : Java : Tech : Physics :
Example: Event Type Simulation
Course Map
Chapter 1
What is Java?
Java 5.0

Java Process
Getting Started
Simple Applet
Simple Application


Making WebPages
Java 5.0 Features
Advanced JVMs
Alt. Compilers
Alt. JVMs
Java Deployment

     About JavaTech
     Codes List
     Topic Index
     Course Guide
     What's New

[Temporary Example]

Buffon's Needle

by Michael J. Hurben

The Java applet should have appeared here. Since it has not, this means (a) your browser is not capable of viewing Java applets (In which case you should consider downloading a new browser from Netscape or Microsoft) or (b) you need to check your browser settings to enable Java.

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

Java in Science
    & Engineering
RealWorld Examples

Java in Physics
Sim. in Experiments
  Demo 1: Event
  Demo 2: Continuous
  Demo 3: Static

Learn by Coding

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
22 23 24

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.