Iterate over count_runs()
, counting the number of applicable trials where
such a trial is defined as having the occurrence of a streak of at least the
designated length. Additionally, keep a running tally of the cumulative likelihood
of obtaining exactly zero streaks.
Usage
run_simulation(
iters,
trials,
sample_space,
sample_probs = NULL,
sample_size,
run_value,
run_length
)
Arguments
- iters
number, number of simulation iterations.
- trials
number, see
count_runs()
.- sample_space
vector, see
count_runs()
.- sample_probs
vector, see
count_runs()
.- sample_size
number, see
count_runs()
.- run_value
number, see
count_runs()
.- run_length
number, see
count_runs()
.
Value
data frame with
4 columns:
iterations
,applicable_trials
,prob_of_zero
, &prob_of_ge_one
; andthe number of rows to be determined by
iters
Details
This function outputs a data frame with four columns: 1.) the iteration number, 2.) the count of applicable trials in that iteration, and 3.) the cumulative probability of obtaining zero streaks. 4.) the cumulative probability of obtaining at least one streak.
Examples
tail(
run_simulation(
iters = 100,
trials = 8,
sample_space = c(0, 1),
sample_size = 5,
run_value = 1,
run_length = 3
)
)
#> iterations applicable_trials prob_of_zero prob_of_ge_one
#> 95 95 1 0.09473684 0.9052632
#> 96 96 3 0.09375000 0.9062500
#> 97 97 5 0.09278351 0.9072165
#> 98 98 4 0.09183673 0.9081633
#> 99 99 2 0.09090909 0.9090909
#> 100 100 3 0.09000000 0.9100000