Description Usage Arguments Value Author(s) Examples
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.
1 | make_game(outcomes, probs, plays)
|
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 |
a function of a single parameter n, with default value 1. n is the number of times you simulate the net winnings.
Homer White hwhite0@georgetowncollege.edu
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.