dask 2021.10.0

NotesParametersReturns
negative_binomial(self, n, p, size=None, chunks='auto', **kwargs)

This docstring was copied from numpy.random.mtrand.RandomState.negative_binomial.

Some inconsistencies with the Dask version may exist.

Samples are drawn from a negative binomial distribution with specified parameters, n successes and p probability of success where n is > 0 and p is in the interval [0, 1].

note

New code should use the negative_binomial method of a default_rng() instance instead; please see the :None:ref:`random-quick-start`.

Notes

The probability mass function of the negative binomial distribution is

$$P(N;n,p) = \frac{\Gamma(N+n)}{N!\Gamma(n)}p^{n}(1-p)^{N},$$

where $n$ is the number of successes, $p$ is the probability of success, $N+n$ is the number of trials, and $\Gamma$ is the gamma function. When $n$ is an integer, $\frac{\Gamma(N+n)}{N!\Gamma(n)} = \binom{N+n-1}{N}$ , which is the more common form of this term in the the pmf. 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.

Parameters

n : float or array_like of floats

Parameter of the distribution, > 0.

p : float or array_like of floats

Parameter of the distribution, >= 0 and <=1.

size : int or tuple of ints, optional

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.

Returns

out : ndarray or scalar

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.

Draw samples from a negative binomial distribution.

See Also

Generator.negative_binomial

which should be used for new code.

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.?

This example is valid syntax, but we were not able to check execution
>>> s = np.random.negative_binomial(1, 0.1, 100000)  # doctest: +SKIP
... for i in range(1, 11): # doctest: +SKIP
...  probability = sum(s<i) / 100000.
...  print(i, "wells drilled, probability of one success =", probability)
See :

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


File: /dask/array/random.py#334
type: <class 'function'>
Commit: