
Generate a random probability based on features of the simulation
Source:R/simulation-utils.R
cfg_beta_prob_rng.Rd
Generate a random probability based on features of the simulation
Arguments
- probability_fn
a function which gives the time-varying mean of a beta distribution, The function will be called minimally with
.x
or `tâ which will be the time as a time period. Other variables may be present.- kappa_fn
a function which gives the time-varying dispersion of a beta distribution. The function will be called with minimally
.x
ort
which will be the time period and.y
ormean
will be the mean. Other variables may be present.
Value
a time dependent function that inputs a time (as a time_period) and
returns an probability for each day defined by the probability_fn
and kappa_fn
Examples
fn = cfg_beta_prob_rng(~ ifelse(.x<=5,0.1,0.9))
fn(1:10)
#> [1] 0.10264974 0.09994303 0.10665743 0.11315549 0.08053910 0.90250820
#> [7] 0.90247668 0.90286478 0.90559741 0.89325780