Correct formulas for the mean and variance of negative binomial distribution According to ScienceDirect and StatTrek, a negative binomial distribution where:
$x$ number of trials, $x = \textrm{1, 2, ...}$
$r$ number of failures, $r = \textrm{1, 2, ... }x$
$k$ number of successes, $k = \textrm{0, 1, ... }(x-r)$
$p$ probability of success, $0<p<1$
The the mean and variance are calculated by:
$$\mathbf E[X_k] = \frac{k}{p}$$
$$\sigma_{X_k}^2 = \frac{k(1-p)}{p^2}$$
However, Wikipedia and this question say they are:
$$\mathbf E[X_k] = \frac{pr}{1-p}$$
$$\sigma_{X_k}^2 = \frac{pr}{(1-p)^2}$$
I am completely lost here.  Can someone please help?
 A: The negative binomial distribution has many different parameterizations, because it arose multiple times in many different contexts. Hilbe's Negative Binomial Regression gives a good overview in case you are interested.

I'll concentrate on tying the Wikipedia (W) and ScienceDirect (SD) articles together. The StatTrek one is a bit hard for me to parse.
In the present case, there are two sources of confusion:


*

*On the one hand, the W article defines the negbin as counting the number of failures until we have a certain number of successes, whereas the SD article defines it as the number of trials (so, failures plus successes).

*On the other hand, the SD article does not explicitly define what $p$ is. It turns out that if SD's $p$ is the probability of failure, whereas W's $p$ is the probability of success, everything falls into place.


Of course, we also have that W denotes the number of successes by $r$ and SD by $k$.

So, let's unify things. Here is our common nomenclature:


*

*$r$ is the number of successes (following W rather than SD)

*$p_W$ is the probability of success

*$p_{SD}$  is the probability of failure, so $p_{SD}=1-p_W$
Now, for our random variables: let


*

*$X_W$ denote the number of failures until we have $r$ successes

*$X_{SD}$ denote the number of trials until we have $r$ successes


So obviously, we have
$$ X_{SD} = X_W+r. $$
Now, do the formulas for the expectation match?
$$ \begin{align*}
 E X_{SD} 
 = & EX_W+r \quad\text{by additivity of the expectation} \\
 = & \frac{p_Wr}{1-p_W}+r \quad\text{from W} \\
 = & \frac{(1-p_{SD})r}{p_{SD}}+r \quad\text{because $p_W=1-p_{SD}$} \\
 = & \frac{r}{p_{SD}} \\
 = & E X_{SD} \quad\text{from SD.}
\end{align*}
$$
So the formulas the expectation match.
For the variance,
$$ \begin{align*}
 \sigma^2_{X_{SD}}
 = &  \sigma^2_{X_W} \quad\text{by additivity of the expectation} \\
 = & \frac{p_Wr}{(1-p_W)^2} \quad\text{from W} \\
 = & \frac{(1-p_{SD})r}{p_{SD}^2} \quad\text{because $p_W=1-p_{SD}$} \\
 = & \sigma^2_{X_{SD}} \quad\text{from SD.}
\end{align*}
$$
So the formulas for the variance also match.
