Consider a sequence of independent Bernoulli trials with success probability p. The distribution of the random variable that represents the number of failures until the first success is called geometric distribution. Now, letX denote the number of failures until the rth success. The random variable X is called the negative binomial random variable with parameters p and r, and its probability mass function is given by

P (X = k|r, p) = P (observing k failures in the first k + r − 1 trials) × P (observing a success at the (k + r)th trial)


( r + k − 1


) pr−1(1− p)k × p.