How can I draw numbers from a Bernoulli distribution using scipy
efficiently?
Asked
Active
Viewed 198 times
0

Fabian Rost
- 2,284
- 2
- 15
- 27
1 Answers
1
You can make use of the fact that the Bernoulli distribution is a special case of the Binomial distribution with n=1
.
Example:
import scipy as sp
p = 0.2
sp.random.binomial(1, p)

Fabian Rost
- 2,284
- 2
- 15
- 27