本文簡要介紹 python 語言中 numpy.random.RandomState.weibull
的用法。
用法:
random.RandomState.weibull(a, size=None)
從 Weibull 分布中抽取樣本。
從具有給定形狀參數 a 的 1 參數 Weibull 分布中抽取樣本。
這裏,U 是從 (0,1] 上的均勻分布中得出的。
更常見的 2 參數 Weibull,包括比例參數 隻是 。
注意
新代碼應改為使用
default_rng()
實例的weibull
方法;請參閱快速入門。- a: 浮點數或類似數組的浮點數
分布的形狀參數。必須是非負數。
- size: int 或整數元組,可選
輸出形狀。例如,如果給定的形狀是
(m, n, k)
,則繪製m * n * k
樣本。如果 size 為None
(默認),如果a
是標量,則返回單個值。否則,將抽取np.array(a).size
樣本。
- out: ndarray 或標量
從參數化的 Weibull 分布中抽取樣本。
參數:
返回:
注意:
Weibull(或最小值的 III 型漸近極值分布、SEV III 型或Rosin-Rammler 分布)是用於建模極值問題的一類廣義極值 (GEV) 分布之一。此類包括 Gumbel 和 Frechet 分布。
Weibull 分布的概率密度為
其中 是形狀, 是比例。
該函數在 處有其峰值(模式)。
當
a = 1
時,威布爾分布減少為 index 分布。參考:
Waloddi Weibull,皇家技術大學,斯德哥爾摩,1939 年“材料強度的統計理論”,Ingeniorsvetenskapsakademiens Handlingar Nr 151,1939 年,Generalstabens Litografiska Anstalts Forlag,斯德哥爾摩。
Waloddi Weibull,“廣泛適用的統計分布函數”,應用力學雜誌 ASME 論文 1951。
維基百科,“Weibull distribution”,https://en.wikipedia.org/wiki/Weibull_distribution
1:
2:
3:
例子:
從分布中抽取樣本:
>>> a = 5. # shape >>> s = np.random.weibull(a, 1000)
顯示樣本的直方圖以及概率密度函數:
>>> import matplotlib.pyplot as plt >>> x = np.arange(1,100.)/50. >>> def weib(x,n,a): ... return (a / n) * (x / n)**(a - 1) * np.exp(-(x / n)**a)
>>> count, bins, ignored = plt.hist(np.random.weibull(5.,1000)) >>> x = np.arange(1,100.)/50. >>> scale = count.max()/weib(x, 1., 5.).max() >>> plt.plot(x, weib(x, 1., 5.)*scale) >>> plt.show()
相關用法
- Python numpy RandomState.wald用法及代碼示例
- Python numpy RandomState.standard_exponential用法及代碼示例
- Python numpy RandomState.bytes用法及代碼示例
- Python numpy RandomState.uniform用法及代碼示例
- Python numpy RandomState.standard_gamma用法及代碼示例
- Python numpy RandomState.seed用法及代碼示例
- Python numpy RandomState.power用法及代碼示例
- Python numpy RandomState.standard_normal用法及代碼示例
- Python numpy RandomState.geometric用法及代碼示例
- Python numpy RandomState.random_sample用法及代碼示例
- Python numpy RandomState.gumbel用法及代碼示例
- Python numpy RandomState.logseries用法及代碼示例
- Python numpy RandomState.noncentral_chisquare用法及代碼示例
- Python numpy RandomState.chisquare用法及代碼示例
- Python numpy RandomState.poisson用法及代碼示例
- Python numpy RandomState.randn用法及代碼示例
- Python numpy RandomState.vonmises用法及代碼示例
- Python numpy RandomState.gamma用法及代碼示例
- Python numpy RandomState.zipf用法及代碼示例
- Python numpy RandomState.triangular用法及代碼示例
- Python numpy RandomState.f用法及代碼示例
- Python numpy RandomState.shuffle用法及代碼示例
- Python numpy RandomState.rayleigh用法及代碼示例
- Python numpy RandomState.randint用法及代碼示例
- Python numpy RandomState.permutation用法及代碼示例
注:本文由純淨天空篩選整理自numpy.org大神的英文原創作品 numpy.random.RandomState.weibull。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。