- np.random.binomial (N, p, size = q)
- np.random.binomial (1, p, size = q)
- np.random.binomial (N, p, size = q)
1st and 3rd are similar, I see. These two are binomial random number generators.
And, the second is a Bernoulli random number generator
Binom Explanation:
A binomial random variable calculates how often a particular event occurs in a fixed number of attempts or trials.
Here
- n = number of tests
- p = probable event of interest occurs in any trial
- size = the number of times you want to run this experiment.
Suppose you want to check how many times you get six if you roll dice 10 times. Here
- n = 10
- p = (1/6) # probability of getting six in each roll
But, you have to do this experiment several times.
Let, in the first experiment you get 3 six
In the 2nd experiment you get 2 six
In the third experiment you get 2 six
In the Pth experiment, you get 2 six, here P is the size
Bernoulli explanation:
Suppose you are performing an experiment with two possible outcomes: either success or failure. Success happens with probability p, while probability 1-p fails. The random variable, which takes the value 1 in case of success and 0 in case of failure, is called the Bernoulli random variable.
Here
- n = 1 because you need to check if it will be success or failure once
- p = probability of success
- size = number of times you check this
You can also read this, numpy.random.binomial
Also, the difference between Binomial and Bernoulli

source share