Monte Carlo Simulation of Galileo's Dice
A Monte Carlo simulation of the Galileo's Dice problem. Returns a vector containing point estimates of the probabilities of the sum of three fair dice for sums 3, 4, …, 18.
galileo(nrep = 1000, seed = NA, showProgress = TRUE)
nrep |
number of replications (rolls of the three dice) |
seed |
initial seed to the random number generator (NA uses current state of random number generator; NULL seeds using system clock) |
showProgress |
If TRUE, displays a progress bar on screen during execution |
Implements a Monte Carlo simulation of the Galileo's Dice problem.
The simulation involves nrep
replications of rolling three dice and
summing the up-faces, and computing point estimates of the probabilities
of each possible sum 3, 4, …, 18.
Note: When the value of nrep
is large, the function will execute
noticeably faster when showProgress
is set to FALSE
.
An 18-element vector of point estimates of the probabilities.
(Because a sum of 1 or 2 is not possible, the corresponding entries in the
returned vector have value NA
.)
Barry Lawson (blawson@richmond.edu),
Larry Leemis (leemis@math.wm.edu),
Vadim Kudlay (vadim.kudlay@richmond.edu)
# set the initial seed externally using set.seed; # then use that current state of the generator with default nrep = 1000 set.seed(8675309) galileo() # uses state of generator set above # explicitly set the seed in the call to the function, # using default nrep = 1000 galileo(seed = 8675309) # use the current state of the random number generator with nrep = 10000 probs <- galileo(10000) # explicitly set nrep = 10000 and seed = 8675309 probs <- galileo(10000, 8675309)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.