<p dir="auto">Currently, there are two formulations in the documentation: (1) in the <code class="notranslate">Returns</code> description, some form of "N trials given n successes" where the last trial is incorrectly indexed as N + n and (2) in the <code class="notranslate">Notes</code>, "N failures given n successes and p(success) = p". <del>However, neither of these descriptions match the variable that is actually returned, which via the gamma-Poisson mixture is "N successes given n failures and p(success) = p".</del> While "N failures given n successes" and "N successes given n failures" have the same expression as their respective pmfs, they are not equivalent except when p=0.5:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
import scipy as sp
import scipy.special

N = np.arange(100)
p = 0.5
# N successes given 5 failures
p0 = sp.special.binom(N + 5 - 1, N) * p**N *(1-p)**5
# N failures given 5 succeses
p1 = sp.special.binom(5 + N - 1, 4)  * p**5 *(1-p)**N
np.allclose(p0 ,p1)
# True

p = 0.75
p0 = sp.special.binom(N + 5 - 1, N) * p**N *(1-p)**5
p1 = sp.special.binom(5 + N - 1, 4)  * p**5 *(1-p)**N
np.allclose(p0, p1)
# False"><pre class="notranslate"><code class="notranslate">import numpy as np
import scipy as sp
import scipy.special

N = np.arange(100)
p = 0.5
# N successes given 5 failures
p0 = sp.special.binom(N + 5 - 1, N) * p**N *(1-p)**5
# N failures given 5 succeses
p1 = sp.special.binom(5 + N - 1, 4)  * p**5 *(1-p)**N
np.allclose(p0 ,p1)
# True

p = 0.75
p0 = sp.special.binom(N + 5 - 1, N) * p**N *(1-p)**5
p1 = sp.special.binom(5 + N - 1, 4)  * p**5 *(1-p)**N
np.allclose(p0, p1)
# False
</code></pre></div>
<p dir="auto">Clearly "N failures given n successes and p(success) = p" is equivalent to "N successes given n failures and p(success) = 1 - p". <del>The quickest solution is to change the description to match  "N successes given n failures and p(success) = p".</del> I also suggest switching to the p(k; r, p) notation used on the negative binomial distribution Wikipedia page.</p>
<p dir="auto">EDIT: On further inspection, the output does match the second description, given the shape and scale parameterization of the gamma distribution. I've changed the title to reflect this.</p>
<p dir="auto">The docstring says that negative_binomial() returns:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="out : ndarray or scalar
    Drawn samples from the parameterized negative binomial distribution,
    where each sample is equal to N, the number of trials it took to
    achieve n - 1 successes, N - (n - 1) failures, and a success on the,
    (N + n)th trial."><pre class="notranslate"><code class="notranslate">out : ndarray or scalar
    Drawn samples from the parameterized negative binomial distribution,
    where each sample is equal to N, the number of trials it took to
    achieve n - 1 successes, N - (n - 1) failures, and a success on the,
    (N + n)th trial.
</code></pre></div>
<p dir="auto">N isn't the number of trials, it's the number of failures. The number of trials (excluding "the (N+n)th trial") is N+n-1, as in the equation in the "Notes" section. The formula N - (n - 1) is wrong too, it should be just N.</p>
<p dir="auto">If the drawn sample were the number of trials, the minimum returned value would be n-1, but it plainly is not:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; np.random.negative_binomial(10, .99)
0
&gt;&gt;&gt;"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">negative_binomial</span>(<span class="pl-c1">10</span>, <span class="pl-c1">.99</span>)
<span class="pl-c1">0</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span></pre></div>