溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

在python中如何求分布函數(shù)相關(guān)的包

發(fā)布時間:2020-08-03 13:51:06 來源:億速云 閱讀:223 作者:小豬 欄目:開發(fā)技術(shù)

這篇文章主要講解了在python中如何求分布函數(shù)相關(guān)的包,內(nèi)容清晰明了,對此有興趣的小伙伴可以學(xué)習(xí)一下,相信大家閱讀完之后會有幫助。

為了了解(正態(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:累計分布函數(shù)

sf:殘存函數(shù)(1-CDF)

ppf:分位點函數(shù)(CDF的逆)

isf:逆殘存函數(shù)(sf的逆)

stats:返回均值,方差,(費舍爾)偏態(tài),(費舍爾)峰度。

moment:分布的非中心矩。

我們以cdf為例:

 >>>norm.cdf(0)
0.5
>>>norm.mean(), norm.std(), norm.var()
(0.0, 1.0, 1.0)

重點來了,cdf的逆竟然也可以求,這個方法就是ppf

>>>norm.ppf(0.5)
0.0

離散分布中,pdf被更換為密度函數(shù)pmf,而cdf的逆也有所不同:

ppf(q) = min{x : cdf(x) >= q, x integer}

此外,fit可以求分布參數(shù)的極大似然估計,包括location與scale,nnlf可以求負(fù)對數(shù)似然函數(shù),expect可以計算函數(shù)pdf或pmf的期望值。

看完上述內(nèi)容,是不是對在python中如何求分布函數(shù)相關(guān)的包有進(jìn)一步的了解,如果還想學(xué)習(xí)更多內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI