This function creates a population from a distribution.

generate_virtual_pop(N, var_name, dist, ...)

Arguments

N

The numbers of samples

var_name

the variable name that we need to create

dist

the distribution function for random variables (starts with 'r', i.e. rnorm, rpois, rexp)

...

for the dist function

Value

a tibble that stores the virtual population

Examples

generate_virtual_pop(100, "height", rnorm, 0, 1)
#> # A tibble: 100 x 1 #> height #> <dbl> #> 1 -0.666 #> 2 -1.13 #> 3 -0.369 #> 4 -1.18 #> 5 0.0593 #> 6 -1.83 #> 7 0.814 #> 8 -1.48 #> 9 -1.42 #> 10 1.94 #> # … with 90 more rows
generate_virtual_pop(100, "n_accidents_per_hr", rpois, 2)
#> # A tibble: 100 x 1 #> n_accidents_per_hr #> <int> #> 1 4 #> 2 1 #> 3 0 #> 4 5 #> 5 3 #> 6 1 #> 7 1 #> 8 1 #> 9 1 #> 10 1 #> # … with 90 more rows