simulate_chance_model: Simulate from a Chance Model

View source: R/simulate_chance_model.R

simulate_chance_modelR Documentation

Simulate from a Chance Model

Description

Simulate from a Chance Model

Usage

simulate_chance_model(chanceSuccess, numDraws, numRepetitions)

Arguments

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.

Value

A vector of simulated proportions of successes. The vector will be the same length as numRepetitions.

Examples

# 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)

STATS250SBI/stats250sbi documentation built on March 18, 2022, 1:14 p.m.