借助numpy.random.rayleigh()方法,我們可以從瑞利分布中獲取隨機樣本並返回隨機樣本。

瑞利分布函數
用法:numpy.random.rayleigh(scale=1.0, size=None)
Return:以numpy數組形式返回隨機樣本。
範例1:
在此示例中,我們可以看到,通過使用numpy.random.rayleigh()方法,我們可以獲得瑞利分布並返回隨機樣本。
Python3
# import numpy
import numpy as np
import matplotlib.pyplot as plt
# Using rayleigh() method
gfg = np.random.rayleigh(3.4, 50000)
plt.figure()
plt.hist(gfg, bins = 50, density = True)
plt.show()
輸出:
範例2:
Python3
# import numpy
import numpy as np
import matplotlib.pyplot as plt
# Using rayleigh() method
gfg = np.random.rayleigh(2 * np.sqrt(np.pi), 100000)
plt.figure()
plt.hist(gfg, bins = 50, density = True)
plt.show()
輸出:
相關用法
- Python numpy.pv()用法及代碼示例
- Python numpy.fv()用法及代碼示例
- Python numpy.npv()用法及代碼示例
- Python numpy.exp()用法及代碼示例
- Python np.nanmax()用法及代碼示例
- Python numpy.ptp()用法及代碼示例
- Python numpy.std()用法及代碼示例
- Python numpy.mean()用法及代碼示例
- Python numpy.inner()用法及代碼示例
- Python numpy.sum()用法及代碼示例
- Python numpy.add()用法及代碼示例
- Python numpy.fix()用法及代碼示例
- Python numpy.log()用法及代碼示例
- Python numpy.where()用法及代碼示例
- Python numpy.var()用法及代碼示例
- Python numpy.around()用法及代碼示例
- Python numpy.tan()用法及代碼示例
- Python numpy.lcm()用法及代碼示例
- Python numpy.gcd()用法及代碼示例
- Python numpy.pmt()用法及代碼示例
注:本文由純淨天空篩選整理自Jitender_1998大神的英文原創作品 numpy.random.rayleigh() in python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。