0

How can I draw numbers from a Bernoulli distribution using scipy efficiently?

Fabian Rost
  • 2,284
  • 2
  • 15
  • 27

1 Answers1

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