View source: R/simulate_chance_model.R
simulate_chance_model | R Documentation |
Simulate from a Chance Model
simulate_chance_model(chanceSuccess, numDraws, numRepetitions)
chanceSuccess |
A number between 0 and 1 representing the probability of observing a "success" (however defined). Can be a decimal or a fraction; e.g., 0.55 or 55/100. |
numDraws |
The number of times to draw a poker chip from the bag needed to complete one repetition of the simulation. Must be a positive, whole number; if not, it will be rounded to the nearest whole number. |
numRepetitions |
The number of times to repeat the simulation process. Must be a positive, whole number; if not, it will be rounded to the nearest whole number. |
A vector of simulated proportions of successes. The vector will be
the same length as numRepetitions
.
# Run 100 repetitions of a simulation in which 26 fair coins are flipped, # where "success" is heads. Store the results as `x`. x <- simulate_chance_model(chanceSuccess = 0.5, numDraws = 26, numRepetitions = 100) # Make a histogram of the results hist(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.