different definitions
Negative binomial distribution NB(k,p), I have seen four definitions in different textbooks and wikis.
- For each experiment with a success rate of p, the number of trials required to achieve k successes (ie the minimum value is k)
- For each experiment with a success rate of p, the number of failures before reaching k successes (ie the minimum value is 0)
- For each experiment with a failure rate of p, the number of trials required to achieve k successes
- For each experiment with a failure rate of p, the number of failures before reaching k successes
Negative binomial distribution (Pascal distribution)
Definition: For each experiment with a success rate of p, the number of failures before reaching k successes (ie the minimum value is 0)
Probability mass function:
Code mock:
- negative_binomial(n, p, size) # nunpy
- nbinom.rvs(n, p, size) # scipy.stats
# nunpy
import numpy as np
rng = np.random.default_rng()
print(rng.negative_binomial(n=1, p=0.5, size=3)) # N次成功前的失败次数
# scipy.stats
from scipy import stats
stats.nbinom.rvs(n=1,p=0.1,size=3) # N次成功前的失败次数