A Good Example
The np.random module and Bernoulli trials
You can think of a Bernoulli trial as a flip of a possibly biased coin. Specifically, each coin flip has a probability pp of landing heads (success) and probability 1−p1−p of landing tails (failure). In this exercise, you will write a function to perform n
Bernoulli trials, perform_bernoulli_trials(n, p)
, which returns the number of successes out of n
Bernoulli trials, each of which has probability p
of success. To perform each Bernoulli trial, use the np.random.random()
function, which returns a random number between zero and one.