# Converting random variable into negative binomial

Original Question:

Suppose that lightbulbs are being tested in a factory, and that they are labeled ($W$) for working and ($F$) for faulty. The lightbulbs are independently selected and tested until two working bulbs have been found sequentially. Let $P(W) = 0.9$ and $P(F) = 0.1$. Let $X$ be the number of bulbs tested. What is $P(X=2)$?

Normally, this can be solved by the following: $$P(X=2) = P(W)\cdot P(W) = 0.81$$

However, what if I wanted to solve this problem with a negative Binomial random variable? How would I then set this problem up?

One formulation of the negative binomial distribution is the distribution of the number of trials in a sequence of independent and identically distributed Bernoulli trials before a specified (non-random) number of non-occurrences occurs. Here your specified event is a faulty lightbulb, and non-occurrence of this event is a working lightbulb. Under your description, you already have a negative binomial random variable. You defined $X$ as the number of bulbs tested until you two working bulbs are found, which has a negative binomial distribution (interpreting the negative binomial in the appropriate formulation for the total number of trials). Hence, you have:
$$\mathbb{P}(X=x) = \text{NegBin}(x | 2, 0.1) = {x-1 \choose 1} 0.1^{x-2} 0.9^2 \text{ } \text{ } \text{ } \text{ } \text{ } \text{ for all } x = 2, 3, 4, ... .$$
$$\mathbb{P}(X=2) = {1 \choose 1} 0.1^0 0.9^2 = 0.81.$$