make_game: Play with a Discrete Random Variable

Description Usage Arguments Value Author(s) Examples

View source: R/make_game.R

Description

Makes a function that simulates a game based where your winnings are the sum of a specified number of plays of a discrete random variable with a specified distribution.

Usage

1
make_game(outcomes, probs, plays)

Arguments

outcomes

numerical vector of possible values of the random variable

probs

numerical vector giving the probability distribution

plays

number of times the random variable is simulated

Value

a function of a single parameter n, with default value 1. n is the number of times you simulate the net winnings.

Author(s)

Homer White hwhite0@georgetowncollege.edu

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
## Not run: 
play_game <- make_gmae(
  outcomes = c(-1, 0, 5)
  probs = c(0.4, 0.5, 0.1)
  plays = 2000
)
## Play "plays" times, get net winnings:
sampler()
## Play "plays" times again:
sampler()
## Play "plays" times, a third time:
sampler()
## 1000 more simulations of the net winnings:
sampler(n = 1000)

## End(Not run)

tigerstats documentation built on July 2, 2020, 2:32 a.m.