本文簡要介紹 python 語言中 scipy.stats.yulesimon
的用法。
用法:
scipy.stats.yulesimon = <scipy.stats._discrete_distns.yulesimon_gen object>#
Yule-Simon 離散隨機變量。
作為
rv_discrete
類的實例,yulesimon
對象從它繼承了一組通用方法(完整列表見下文),並用特定於此特定發行版的詳細信息來完成它們。注意:
yulesimon
的概率質量函數為:對於
scipy.special.beta
函數。 ,其中 。這裏 指的是隨機變量的抽樣基於 [1] 的第 6.3 節第 553 頁。我們的符號通過 映射到引用的邏輯。
有關詳細信息,請參閱維基百科條目 [2]。
參考:
[1]Devroye,盧克。 “非均勻隨機變量生成”,(1986) Springer,紐約。
上麵的概率質量函數以“standardized” 形式定義。要轉移分布,請使用
loc
參數。具體來說,yulesimon.pmf(k, alpha, loc)
等同於yulesimon.pmf(k - loc, alpha)
。例子:
>>> import numpy as np >>> from scipy.stats import yulesimon >>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots(1, 1)
計算前四個時刻:
>>> alpha = 11 >>> mean, var, skew, kurt = yulesimon.stats(alpha, moments='mvsk')
顯示概率質量函數(
pmf
):>>> x = np.arange(yulesimon.ppf(0.01, alpha), ... yulesimon.ppf(0.99, alpha)) >>> ax.plot(x, yulesimon.pmf(x, alpha), 'bo', ms=8, label='yulesimon pmf') >>> ax.vlines(x, 0, yulesimon.pmf(x, alpha), colors='b', lw=5, alpha=0.5)
或者,可以調用分布對象(作為函數)來固定形狀和位置。這將返回一個 “frozen” RV 對象,其中包含固定的給定參數。
凍結分布並顯示凍結的
pmf
:>>> rv = yulesimon(alpha) >>> ax.vlines(x, 0, rv.pmf(x), colors='k', linestyles='-', lw=1, ... label='frozen pmf') >>> ax.legend(loc='best', frameon=False) >>> plt.show()
檢查
cdf
和ppf
的準確性:>>> prob = yulesimon.cdf(x, alpha) >>> np.allclose(x, yulesimon.ppf(prob, alpha)) True
生成隨機數:
>>> r = yulesimon.rvs(alpha, size=1000)
相關用法
- Python SciPy stats.yeojohnson_normmax用法及代碼示例
- Python SciPy stats.yeojohnson_llf用法及代碼示例
- Python SciPy stats.yeojohnson用法及代碼示例
- Python SciPy stats.yeojohnson_normplot用法及代碼示例
- Python SciPy stats.anderson用法及代碼示例
- Python SciPy stats.iqr用法及代碼示例
- Python SciPy stats.genpareto用法及代碼示例
- Python SciPy stats.skewnorm用法及代碼示例
- Python SciPy stats.cosine用法及代碼示例
- Python SciPy stats.norminvgauss用法及代碼示例
- Python SciPy stats.directional_stats用法及代碼示例
- Python SciPy stats.invwishart用法及代碼示例
- Python SciPy stats.bartlett用法及代碼示例
- Python SciPy stats.levy_stable用法及代碼示例
- Python SciPy stats.page_trend_test用法及代碼示例
- Python SciPy stats.itemfreq用法及代碼示例
- Python SciPy stats.exponpow用法及代碼示例
- Python SciPy stats.gumbel_l用法及代碼示例
- Python SciPy stats.chisquare用法及代碼示例
- Python SciPy stats.semicircular用法及代碼示例
- Python SciPy stats.gzscore用法及代碼示例
- Python SciPy stats.gompertz用法及代碼示例
- Python SciPy stats.normaltest用法及代碼示例
- Python SciPy stats.dirichlet_multinomial用法及代碼示例
- Python SciPy stats.genlogistic用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.stats.yulesimon。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。