負の二項分布
Contents
負の二項分布
負の二項分布 (英:nagative binomial distribution) とは、互いに独立で同一なベルヌーイ試行を複数回行い、初めて 回成功するまでの失敗回数の確率変数 が従う離散確率分布のこと。
確率質量関数
確率質量関数の導出:
回目の試行にて、初めて成功回数が 回目となることから、 回目の時点で成功回数は 、失敗回数は である。よって確率質量関数は、
確率質量関数のグラフ:
Python 3
from scipy.stats import nbinom
import matplotlib.pyplot as plt
cases = [
(1, .5), # r, p
(2, .5),
(4, .5),
]
plt.figure()
for r,p in cases:
x = range(10)
dist = nbinom.pmf(x,r,p)
plt.plot(x, dist, label="r={}, p={}".format(r,p))
plt.title("PMF of negative binomial distribution")
plt.xlabel("Number of failures".format(n))
plt.ylabel("Probability".format(n))
plt.legend()
plt.show()
累積分布関数
累積分布関数のグラフ:
Python 3
from scipy.stats import nbinom
import matplotlib.pyplot as plt
cases = [
(1, .5), # r, p
(2, .5),
(4, .5),
]
plt.figure()
for r,p in cases:
x = range(10)
dist = nbinom.cdf(x,r,p)
plt.plot(x, dist, label="r={}, p={}".format(r,p))
plt.title("CDF of negative binomial distribution")
plt.xlabel("Number of failures".format(n))
plt.ylabel("Probability".format(n))
plt.legend()
plt.show()