Negative Binomial Distribution#
Probability Mass Function#
\[f(k, r, p) = \P( X = k ) = \binom{k+r-1}{k} p^k (1-p)^{r}\]
with the number of failures \(r\), the number of successes \(k\), and the success probability \(p\).
import numpy as np
import matplotlib.pyplot as plt
import scipy.stats as st
n = 30; p1 = 1/6.0; p2 = 0.5;
lx = np.arange(0,n+1)
plt.plot(lx, st.binom.pmf(lx, n, p1), label='n= 30, p= 1/6 ' )
plt.plot(lx, st.binom.pmf(lx, n, p2), label='n= 30, p= 1/2 ' )
plt.show()