Skip to contents

Sample value from a given prior sampling formula object

Usage

sample_prior(f)

Arguments

f

Formula-based prior sampling expression such as <variable> ~ <sampling statement>

Value

A list of two elements: "variable" containing the name of the sampled variable, and "value" containing the actual value of the sampled prior.

Examples

priors <- list(
  Ne_A  ~ runif(1000, 3000),
  Ne_B  ~ runif(100,  1500),
  Ne_C  ~ runif(5000, 10000),
  Ne_D  ~ runif(2000, 7000),

  T_AB  ~ runif(1,    4000),
  T_BC  ~ runif(3000, 9000),
  T_CD  ~ runif(5000, 10000),

  gf_BC ~ runif(0, 0.3)
)

sample_prior(priors[[1]])
#> $variable
#> [1] "Ne_A"
#> 
#> $value
#> [1] 1487.138
#> 
sample_prior(param ~ rnorm(0, 1))
#> $variable
#> [1] "param"
#> 
#> $value
#> [1] -0.5512775
#>