Skip to content

Bernoulli random variable with different probability

2 messages · Carrie Li, Erik Iverson

#
Carrie Li wrote:
<snip>

I don't think either.

Try this:

probs <- seq(0,1, by = .1)
sapply(probs, function(x) sample(0:1, 1, prob = c(1-x, x)))

probs will be the vector of your probabilities for obtaining a '1' per subject, 
so set that to whatever you want, then run the second line.