CMPS 3350 Week-9 Monday Programming

Monte Carlo Method

Copy your 3350/9/rand.cpp program to 3350/9/montecarlo.cpp

Log on to Odin and do this:

  $ cd 3350
  $ ./lab-start.sh
  $ cd 9
  $ cp rand.cpp montecarlo.cpp


Use the Monte Carlo method to calculate the probability that
three students in a row will be chosen by the Random Student Generator.

   Random Student Generator

Each student will program their own solution to this. The only restriction
is that you use the Monte Carlo Method, and not probability formulas.

You may use probability formulas to check your work.

The output can be something like shown below.

Sample output...
$ ./montecarlo Number of tries: 10 million Instances found: nnnn Probability: 0.nnnnnnn 1 in every: nnn.nnnnn tries
Probability = Instances found / Number of tries 1 in every = 1 / Probability Note: If you did not write this program in class from the big-screen, you should try to write it from memory or from your notes. I do not recommend that you copy the program from another student.