When \(k\) is the number of failures until the \(r\)th success,
with a probability \(p\) of a success, the negative binomial has density:
$$\left(\frac{r + k - 1}{k}\right) (p)^{r} (1 - p)^{k}$$
for \(k \in \{0, 1, \dots \}\)
When \(k\) is the number of trials until the \(r\)th success,
with a probability \(p\) of a success, the negative binomial has density:
$$\left(\frac{k - 1}{r - 1}\right) (p)^{r} (1 - p)^{k - r}$$
for \(k \in \{r, r + 1, r + 2, \dots \}\)
The alternative parameterization of the negative binomial with parameter
\(\beta\), and \(k\) being the number of trials, has density:
$$\frac{\Gamma(r + k)}{\Gamma(r) k!} \left(\frac{1}{1 + \beta}\right)^{r}%
\left(\frac{\beta}{1 + \beta}\right)^{k - r}$$
for \(k \in \{0, 1, \dots \}\)