0

I have a set of probability corresponding to Bernoulli experiment. How to draw Bernoulli random number given these specific probability from a uniform(0,1) distribution. I know we can draw from binom, but using uniform distribution can vectorize the operation and make it so much faster.

1 Answers1

4

It sounds like you're asking how to simulate independent draws from a Bernoulli distribution with a given probability $p$ when all you have is independent draws from a uniform distribution on $[0, 1]$. That's easy: for each value $x$ drawn from the uniform distribution, return 1 if $x < p$ and 0 otherwise.

Kodiologist
  • 19,063
  • 2
  • 36
  • 68