# The special case of the negative binomial, the geometric and calculation with scipy

### A particular case?

One might consider the geometric distribution is simply a special case of the negative binomial with $N=1$.

We know the geometric provides: "The probability the first occurrence of a success will occur on the $x^{th}$ year". Say for $p=0.1$, $q=1-p$, and $x=8$ this is given by:

$$f_x(8; 0.1) = pq^{x-1} = 0.1 \cdot 0.9^{7}$$

Now, if we want the particular case of the negative binomial, for the first year:

$$f_x(8; 1, 0.1) = \binom{x-1}{k-1}p^kq^{x-k} = \binom{7}{0} 0.1^1 0.9^{7}$$

But when I use scipy I have a slightly different result, and need to reduce my $x$ value by one for the negative binomial:

from scipy.stats import nbinom, geom
N = 1 # first year
p = 0.1 #ten year flood

f_geom = geom(p).pmf
print("""The probability from the geometric distribution
that the first occurrence of a 10-year flood will occur on the
8th year is:
{0:8.5f}""".format(f_geom(8)))

f_nbinom = nbinom(N, p).pmf
print("""The probability from the negative binomial that
a 10-year flood will occur the first time on the
8th year is:
{0:8.5f}""".format(f_nbinom(7)))


Yields:

The probability from the geometric distribution
that the first occurrence of a 10-year flood will occur on the
8th year is:
0.04783

The probability from the negative binomial that
a 10-year flood will occur the first time on the
8th year is:
0.04783


Could someone provide an explanation for this?

• Its simply the number of trials vs number of failures versions of the geometric/ negative binomial. This is explicit at the Wikipedia geometric distribution article Commented Sep 6, 2017 at 0:08

nbinom.pmf(k) = choose(k+n-1, n-1) * p**n * (1-p)**k

The nbinom function takes the number of failures as its input, which is one less than the total number of trials i.e. including the successful trial. The geometric distribution, as you state, is defined for the total number of trials including the success.