本文簡要介紹 python 語言中 scipy.stats.powernorm
的用法。
用法:
scipy.stats.powernorm = <scipy.stats._continuous_distns.powernorm_gen object>#
冪正態連續隨機變量。
作為
rv_continuous
類的實例,powernorm
對象從它繼承了一組通用方法(完整列表見下文),並用特定於此特定發行版的詳細信息來完成它們。注意:
powernorm
的概率密度函數為:其中 是普通 pdf, 是普通 cdf, 是任意實數, [1]。
powernorm
將c
作為 的形狀參數。上麵的概率密度在“standardized” 表格中定義。要移動和/或縮放分布,請使用
loc
和scale
參數。具體來說,powernorm.pdf(x, c, loc, scale)
等同於powernorm.pdf(y, c) / scale
和y = (x - loc) / scale
。請注意,移動分布的位置不會使其成為“noncentral” 分布;某些分布的非中心概括可在單獨的類中獲得。參考:
[1]NIST 工程統計手冊,第 1.3.6.6.13 節,https://www.itl.nist.gov/div898/handbook//eda/section3/eda366d.htm
例子:
>>> import numpy as np >>> from scipy.stats import powernorm >>> import matplotlib.pyplot as plt >>> fig, ax = plt.subplots(1, 1)
計算前四個時刻:
>>> c = 4.45 >>> mean, var, skew, kurt = powernorm.stats(c, moments='mvsk')
顯示概率密度函數(
pdf
):>>> x = np.linspace(powernorm.ppf(0.01, c), ... powernorm.ppf(0.99, c), 100) >>> ax.plot(x, powernorm.pdf(x, c), ... 'r-', lw=5, alpha=0.6, label='powernorm pdf')
或者,可以調用分布對象(作為函數)來固定形狀、位置和比例參數。這將返回一個 “frozen” RV 對象,其中包含固定的給定參數。
凍結分布並顯示凍結的
pdf
:>>> rv = powernorm(c) >>> ax.plot(x, rv.pdf(x), 'k-', lw=2, label='frozen pdf')
檢查
cdf
和ppf
的準確性:>>> vals = powernorm.ppf([0.001, 0.5, 0.999], c) >>> np.allclose([0.001, 0.5, 0.999], powernorm.cdf(vals, c)) True
生成隨機數:
>>> r = powernorm.rvs(c, size=1000)
並比較直方圖:
>>> ax.hist(r, density=True, bins='auto', histtype='stepfilled', alpha=0.2) >>> ax.set_xlim([x[0], x[-1]]) >>> ax.legend(loc='best', frameon=False) >>> plt.show()
相關用法
- Python SciPy stats.powerlognorm用法及代碼示例
- Python SciPy stats.powerlaw用法及代碼示例
- Python SciPy stats.power_divergence用法及代碼示例
- Python SciPy stats.poisson用法及代碼示例
- Python SciPy stats.poisson_means_test用法及代碼示例
- Python SciPy stats.pointbiserialr用法及代碼示例
- Python SciPy stats.page_trend_test用法及代碼示例
- Python SciPy stats.pareto用法及代碼示例
- Python SciPy stats.planck用法及代碼示例
- Python SciPy stats.ppcc_plot用法及代碼示例
- Python SciPy stats.probplot用法及代碼示例
- Python SciPy stats.ppcc_max用法及代碼示例
- Python SciPy stats.pmean用法及代碼示例
- Python SciPy stats.pearson3用法及代碼示例
- Python SciPy stats.pearsonr用法及代碼示例
- Python SciPy stats.percentileofscore用法及代碼示例
- Python SciPy stats.permutation_test用法及代碼示例
- 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用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.stats.powernorm。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。