| Integrating Empirical Methods into Computer Science | |
|
Project Goals Required Skills Lab Repository Related Papers Collaborators Feedback |
||
Empirical Lab RepositoryTitle: Monte Carlo Methods: Approximating PI Author: Dave Reed, Creighton University, davereed@creighton.edu Possible Courses: CS0, CS1 Empirical Concepts Introduced: Monte Carlo Methods, expected values, consistency, accuracy Computer Science Concepts Used: computer-based simulation, input/output, arithmetic operations Summary:
This assignment uses a Java applet to introduce the concept of
Monte Carlo methods. Using the existing Web page, students are led through a
series of experiments to count the number of random dots that land inside a
circle. The concepts of expected value and consistency are introduced,
as students perform repeated experiments, average the results, and measure the
differences between the values obtained. Once the students have collected data
(the number of dots that landed inside the circle)
from repeated experiments, that data is used to
calculate estimates of PI based on a provided formula. Students are asked to write
a
simple program that takes the data from the experiments, computes an approximation
of PI,
and displays that approximation. The concept of accuracy and
its distinction from consistency is discussed. In addition, the Law of Large
Numbers
is implicit (although not mentioned by name) as students perform repeated trials,
noting the increase in consistency and accuracy as the number of trials increases.
Variations: If desired, an instructor could use the idea for this assignment later in a programming course. Instead of providing the Web page with the applet, the instructor could assign the task of performing the simulation and counting the dots to the student. A program for conducting such as simulation is relatively short, but covers many of the fundamental programming constructs, including mathematical functions, conditionals, loops, and counters.
|