本文簡要介紹 python 語言中 scipy.stats.dlaplace
的用法。
用法:
scipy.stats.dlaplace = <scipy.stats._discrete_distns.dlaplace_gen object>#
拉普拉斯離散隨機變量。
作為
rv_discrete
類的實例,dlaplace
對象從它繼承了一組通用方法(完整列表見下文),並用特定於此特定發行版的詳細信息來完成它們。注意:
dlaplace
的概率質量函數為:對於整數 和 。
dlaplace
將 作為形狀參數。上麵的概率質量函數以“standardized” 形式定義。要轉移分布,請使用
loc
參數。具體來說,dlaplace.pmf(k, a, loc)
等同於dlaplace.pmf(k - loc, a)
。例子:
>>> import numpy as np >>> from scipy.stats import dlaplace >>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots(1, 1)
計算前四個時刻:
>>> a = 0.8 >>> mean, var, skew, kurt = dlaplace.stats(a, moments='mvsk')
顯示概率質量函數(
pmf
):>>> x = np.arange(dlaplace.ppf(0.01, a), ... dlaplace.ppf(0.99, a)) >>> ax.plot(x, dlaplace.pmf(x, a), 'bo', ms=8, label='dlaplace pmf') >>> ax.vlines(x, 0, dlaplace.pmf(x, a), colors='b', lw=5, alpha=0.5)
或者,可以調用分布對象(作為函數)來固定形狀和位置。這將返回一個 “frozen” RV 對象,其中包含固定的給定參數。
凍結分布並顯示凍結的
pmf
:>>> rv = dlaplace(a) >>> 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 = dlaplace.cdf(x, a) >>> np.allclose(x, dlaplace.ppf(prob, a)) True
生成隨機數:
>>> r = dlaplace.rvs(a, size=1000)
相關用法
- Python SciPy stats.directional_stats用法及代碼示例
- Python SciPy stats.dirichlet_multinomial用法及代碼示例
- Python SciPy stats.dweibull用法及代碼示例
- Python SciPy stats.dunnett用法及代碼示例
- Python SciPy stats.differential_entropy用法及代碼示例
- Python SciPy stats.dgamma用法及代碼示例
- Python SciPy stats.describe用法及代碼示例
- Python SciPy stats.dirichlet用法及代碼示例
- 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.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用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.stats.dlaplace。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。