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.