dpnp.random.binomial
- dpnp.random.binomial(n, p, size=None)[source]
Draw samples from a binomial distribution.
For full documentation refer to
numpy.random.binomial
.Limitations
Output array data type is
dpnp.int32
. Parameters n and p are supported as scalar. Otherwise,numpy.random.binomial(n, p, size)
samples are drawn.Examples
Draw samples from the distribution:
>>> n, p = 10, .5 # number of trials, probability of each trial >>> s = dpnp.random.binomial(n, p, 1000) # result of flipping a coin 10 times, tested 1000 times. A real world example. A company drills 9 wild-cat oil exploration wells, each with an estimated probability of success of 0.1. All nine wells fail. What is the probability of that happening? Let's do 20,000 trials of the model, and count the number that generate zero positive results. >>> sum(dpnp.random.binomial(9, 0.1, 20000) == 0)/20000. # answer = 0.38885, or 38%.