galileo {simEd}R Documentation

Monte Carlo Simulation of Galileo's Dice

Description

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, \ldots, 18.

Usage

galileo(nrep = 1000, seed = NA, showProgress = TRUE)

Arguments

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

Details

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, \ldots, 18.

Note: When the value of nrep is large, the function will execute noticeably faster when showProgress is set to FALSE.

Value

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.)

Author(s)

Barry Lawson (blawson@bates.edu),
Larry Leemis (leemis@math.wm.edu),
Vadim Kudlay (vkudlay@nvidia.com)

Examples

 # 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
 prob <- galileo(10000)

 # explicitly set nrep = 10000 and seed = 8675309
 prob <- galileo(10000, 8675309)


[Package simEd version 2.0.1 Index]