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.
Asked
Active
Viewed 3,435 times
1 Answers
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
-
Why is that Bernoulli number? Can you explain it a bit more? – News_is_Selection_Bias Oct 15 '16 at 01:06
-
1Why is the result Bernoulli-distributed, you mean? Because all that's required is to return 1 with probability $p$, and the uniform distribution on $[0, 1]$ means that the chance of $x$ landing in $[0, p]$ is $p$. – Kodiologist Oct 15 '16 at 01:09
-
Yes, why the result is Bernoulli distributed why when x – News_is_Selection_Bias Oct 15 '16 at 01:53
-
Because that's how the uniform distribution is defined. I'm not sure what more there is to say without getting into measure theory or something, which I doubt you would find enlightening. – Kodiologist Oct 15 '16 at 03:05