Tricky Negative Binomial example Let $Y$ count the number of widgets succesfully produced before $r$th failure. We are told that machine shuts down when $30$th failure has occured, that is $r=30$. Then probability of producing $y$ widgets before machine shuts down is given by Negative Binomial pmf
\begin{equation}
\mathbb{P}(Y=y)=
\begin{pmatrix}
y+r-1\\ y 
\end{pmatrix}
(1-p)^rp^y=\begin{pmatrix}
y+29\\ y 
\end{pmatrix}
(1-p)^{30}p^y .
\end{equation}
WHAT IS THE PROBABILITY THAT MACHINE SHUTS DOWN BEFORE PRODUCING 3 WIDGETS?
Firstly, I have tried to use the pmf of $Y$ in the following way.
$\mathbb{P}\Bigg( machine\ shuts\ down\ before\ 3\ widgets \Bigg)=\mathbb{P}(Y=0)+\mathbb{P}(Y=1)+\mathbb{P}(Y=2)$
that is the sum of probabilities that 0,1,2 widgets produced before machine shuts down.
Then I constructed random variable $X$ that counts failures before $r$th successes, that $X$ pmf is the same as $Y$, with difference of counting probabilities
\begin{equation}
\mathbb{P}(X=x)=
\begin{pmatrix}
x+r-1\\ y 
\end{pmatrix}
(1-p)^xp^r
\end{equation}
thus setting $r=3$ the required probability can be presented as
\begin{equation}
\mathbb{P}(X=30)=
\begin{pmatrix}
30+3-1\\ 30 
\end{pmatrix}
(1-p)^{30}p^3=\begin{pmatrix}
32\\ 30 
\end{pmatrix}
(1-p)^{30}p^3
\end{equation}
PROBLEM!!! The required probability calculated as the sum is NOT the same as one calculated using $X$.
ANY EXPLANATION WHERE DID I MISS THE POINT?
 A: Note: Although the formulation of the two approaches looks quite similar they describe two different situations.
Let's state the problem:

Problem: A machine producing widgets shuts down when the $30$th failure has occured ($r=30$). The probability of producing a widget without failure is $p$. What is the probability that the machine shuts down before producing 3 widgets?
First approach:
We have to keep in mind two crucial aspects of the problem
  
  
*
  
*The machine terminates with the $30$th failure
  
*There are $0,1$ or $2$ widgets which may be successfully produced before the terminating event occurs
We conclude: 
Due to the termination with the $30$th failure we have event chains of length exactly $30,31$ or $32$ depending on $0,1$ or $2$ successfully produced widgets.
Since the last terminating event is always a failure event, we have event chains of length $29, 30$ or $31$ where we may distribute $0,1$ or $2$ sucessfully produced widgets, leaving the last event with probability $1-p$ for a failure event.
Let $Y\in\{0,1,2\}$ be a random variable denoting the number of successfully produced widgets. We get:
\begin{align*}
\mathbb{P}(Y=0)=\binom{29}{0}p^0(1-p)^{30}\\
\mathbb{P}(Y=1)=\binom{30}{1}p^1(1-p)^{30}\\
\mathbb{P}(Y=2)=\binom{31}{2}p^2(1-p)^{30}\\
\end{align*}

These formulae correspond to the negative binomial distribution
\begin{align*}
\mathbb{P}(Y=y)&=\binom{y+r-1}{y }p^y(1-p)^r\\
&=\binom{y+29}{y}p^y(1-p)^{30} \qquad \qquad y\in\{0,1,2\}
\end{align*}

and the (correct) result is according to this approach:
$$\mathbb{P}(Y=0)+\mathbb{P}(Y=1)+\mathbb{P}(Y=2)$$



Second approach:
Now, let $X$ be a random variable counting the number of failures before the $r$-th success. Let's further consider the expression:

\begin{align*}
\mathbb{P}(X=30)=\binom{32}{2}p^3(1-p)^{30}=\left(\binom{32}{2}p^2(1-p)^{30}\right)\cdot p\tag{1}\\
\end{align*}

We observe, the RHS of (1) counts the number of event chains of length $33$, whereby exactly two successes and $30$ failures occur giving $\binom{32}{2}$ possibilities, before the $3$rd success with probability $p$ happens.

Attention: This approach contradicts the crucial aspects from above which we have to follow:

  
*
  
*When focusing on the event chains up to the $32$nd event (before the $3$rd success) we have no longer necessarily the situation, that the terminating $32nd$ event is a failure. The termination condition is violated.
  
*We observe that since the last event of the event-chain of length $32$ can be either a failure or success we erroneously count as follows
  \begin{equation*}
\binom{32}{2}=
\begin{cases}
\binom{31}{1}&\text{last event is a success}\\
+&\\
\binom{31}{2}&\text{last event is a failure}\\
\end{cases}
\end{equation*}
  
*Furthermore the length conditions having length $30,31,32$ (including the terminating failure event) of the event chains from above are also violated. Filling the smaller chains at the right end with success events in (1) is not a proper substitute, since we then erroneously also multiply with $p^3$ which is not correct.

Conclusion: The second approach does not properly describe the above stated problem.
