monty {ipsRdbs}R Documentation

Simulation of the Monty Hall Problem. This demonstrates that switching is always better than staying with the initial guess. Programme written by Corey Chivers, 2012

Description

Simulation of the Monty Hall Problem. This demonstrates that switching is always better than staying with the initial guess. Programme written by Corey Chivers, 2012

Usage

monty(strat = "stay", N = 1000, print_games = TRUE)

Arguments

strat

Strategy to use; possibilities are:

  • "stay": Do not change the initial door chosen.

  • "swap": Swap the door chosen initially.

  • "random": Randomly decide to stay or swap.

N

How many games to play, defaults to 1000.

print_games

Logical; whether to print the results of each game.

Value

No return value, called for side effects. If the supplied parameter print_games is TRUE, then it prints out the result (Win or Loss) of each of the N simulated games. Finally it reports the overall percentage of winning.

####################################################

Source

Corey Chivers (2012) Chivers (2012)

Examples

# example code
monty("stay")
monty("switch")
monty("random")

[Package ipsRdbs version 1.0.0 Index]