abgame: Coin Flip versus Die Roll Game

Description Usage Details Value References Examples

Description

This function simulates a game involving two players. Person A flips a fair coin initially, with the objective of getting a head. Person B rolls a fair six-sided die after Person A's move with the obejective of getting a 1, 2, 3, or 4. The game is repeated until one person is able to complete his or her objective first thereby winning the game. The winner of the game receives a 1 while the loser receives a 0.

Usage

1

Details

The function plays one round of the game referenced in Example 1.4.8 (8th Edition). There is no input required to run this simulation. The function defines all possible outcomes of a coin toss or the rolling of a die, as well as calculates the probability of both the coin landing on heads, and the die landing on one through four.

Value

results contains the resulting score of one round of the game.

References

Hogg, R., McKean, J., Craig, A. (2018) Introduction to Mathematical Statistics, 8th Ed. Boston: Pearson.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
ind <- 0
nsims <- 10000
for (i in 1:nsims) {
    seeA <- abgame()
    if (seeA[1] == 1){
        ind <- ind + 1
    }
}
estpA <- ind/nsims
err <- 1.96 * sqrt(estpA * (1 - estpA)/ nsims)
estpA; err

austinragotzy/mathstat documentation built on May 13, 2019, 11:30 a.m.