Draw samples from a negative binomial distribution.
Samples are drawn from a negative binomial distribution with specified parameters, n successes and p probability of success where n is an integer > 0 and p is in the interval [0, 1].
Parameters:Parameter of the distribution, > 0. Floats are also accepted, but they will be truncated to integers.
Parameter of the distribution, >= 0 and <=1.
Output shape. If the given shape is, e.g., (m, n, k)
, then m * n * k
samples are drawn. If size is None
(default), a single value is returned if n
and p
are both scalars. Otherwise, np.broadcast(n, p).size
samples are drawn.
Drawn samples from the parameterized negative binomial distribution, where each sample is equal to N, the number of failures that occurred before a total of n successes was reached.
Notes
The probability density for the negative binomial distribution is
where is the number of successes, is the probability of success, and is the number of trials. The negative binomial distribution gives the probability of N failures given n successes, with a success on the last trial.
If one throws a die repeatedly until the third time a â1â appears, then the probability distribution of the number of non-â1âs that appear before the third â1â is a negative binomial distribution.
References
Examples
Draw samples from the distribution:
A real world example. A company drills wild-cat oil exploration wells, each with an estimated probability of success of 0.1. What is the probability of having one success for each successive well, that is what is the probability of a single success after drilling 5 wells, after 6 wells, etc.?
>>> s = np.random.negative_binomial(1, 0.1, 100000) >>> for i in range(1, 11): ... probability = sum(s<i) / 100000. ... print i, "wells drilled, probability of one success =", probability
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4