/ math / statistics / probability-distributions /

[edit]

Probability Mass Function

f(k, r, p) = \mathop{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.

Negative Binomial Distribution NB(k, r, p) over k for r = 10 and p = 0.3




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()

References