在python中求分布函數(shù)相關(guān)的包實(shí)例
為了了解(正態(tài))分布的方法和屬性,我們首先引入norm
>>>from scipy.stats import norm >>>rv = norm() >>>dir(rv) # reformatted[‘__class__’, ‘__delattr__’, ‘__dict__’, ‘__doc__’, ‘__getattribute__’,‘__hash__’, ‘__init__’, ‘__module__’, ‘__new__’, ‘__reduce__’, ‘__reduce_ex__’,‘__repr__’, ‘__setattr__’, ‘__str__’, ‘__weakref__’, ‘a(chǎn)rgs’, ‘cdf’, ‘dist’,‘entropy’, ‘isf’, ‘kwds’, ‘moment’, ‘pdf’, ‘pmf’, ‘ppf’, ‘rvs’, ‘sf’, ‘stats’]
其中,連續(xù)隨機(jī)變量的主要公共方法如下:
rvs: Random Variates pdf: Probability Density Function cdf: Cumulative Distribution Function sf: Survival Function (1-CDF) ppf: Percent Point Function (Inverse of CDF) isf: Inverse Survival Function (Inverse of SF) stats: Return mean, variance, (Fisher’s) skew, or (Fisher’s) kurtosis moment: non-central moments of the distribution
rvs:隨機(jī)變量
pdf:概率密度函。
cdf:累計(jì)分布函數(shù)
sf:殘存函數(shù)(1-CDF)
ppf:分位點(diǎn)函數(shù)(CDF的逆)
isf:逆殘存函數(shù)(sf的逆)
stats:返回均值,方差,(費(fèi)舍爾)偏態(tài),(費(fèi)舍爾)峰度。
moment:分布的非中心矩。
我們以cdf為例:
>>>norm.cdf(0)0.5>>>norm.mean(), norm.std(), norm.var()(0.0, 1.0, 1.0)
重點(diǎn)來了,cdf的逆竟然也可以求,這個(gè)方法就是ppf
>>>norm.ppf(0.5)0.0
離散分布中,pdf被更換為密度函數(shù)pmf,而cdf的逆也有所不同:
ppf(q) = min{x : cdf(x) >= q, x integer}
此外,fit可以求分布參數(shù)的極大似然估計(jì),包括location與scale,nnlf可以求負(fù)對(duì)數(shù)似然函數(shù),expect可以計(jì)算函數(shù)pdf或pmf的期望值。
以上這篇在python中求分布函數(shù)相關(guān)的包實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. PHP使用Swagger生成好看的API文檔2. ASP.NET MVC使用jQuery ui的progressbar實(shí)現(xiàn)進(jìn)度條3. Python3 json模塊之編碼解碼方法講解4. Python 制作查詢商品歷史價(jià)格的小工具5. Python 如何調(diào)試程序崩潰錯(cuò)誤6. Python 利用Entrez庫(kù)篩選下載PubMed文獻(xiàn)摘要的示例7. ASP基礎(chǔ)知識(shí)VBScript基本元素講解8. python使用jenkins發(fā)送企業(yè)微信通知的實(shí)現(xiàn)9. Python sublime安裝及配置過程詳解10. Python 合并拼接字符串的方法

網(wǎng)公網(wǎng)安備