This function samples from binomial distribution using a vector of probabilities.

rbinom_vec(probs)

Arguments

probs

a vector of probabilities

Value

a binary vector of binomial observations corresponding to provided probabilities.

Examples

probs <- runif(100)
rbinom_vec(probs)
#>   [1] 0 0 1 0 1 0 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 0 1 0 0 1 1 0 1 0 1 0 1 0 0 0 0
#>  [38] 0 0 1 0 0 1 1 0 0 1 0 0 0 1 0 1 1 1 0 0 1 0 0 1 1 0 0 1 1 0 1 0 0 0 0 0 1
#>  [75] 1 0 1 0 0 0 1 1 1 0 1 0 0 0 1 1 0 0 1 1 1 1 1 0 0 1