Python中的 numpy.random.standard_gamma()
借助numpy.random.standard_gamma()方法,我们可以从标准 gamma 分布中获取随机样本,并使用该方法返回随机样本。
Syntax : numpy.random.standard_gamma(shape, size=None)
Return : Return the random samples as numpy array.
示例 #1:
在这个例子中,我们可以看到通过使用numpy.random.standard_gamma()方法,我们能够从标准 gamma 分布中获取随机样本并返回随机样本。
Python3
# import numpy
import numpy as np
import matplotlib.pyplot as plt
# Using standard_gamma() method
gfg = np.random.standard_gamma(3.47, 5000)
plt.hist(gfg, bins = 50, density = True)
plt.show()
Python3
# import numpy
import numpy as np
import matplotlib.pyplot as plt
# Using standard_gamma() method
gfg = np.random.standard_gamma(3.47, 5000)
gfg1 = np.random.power(gfg, 5000)
plt.hist(gfg1, bins = 50, density = True)
plt.show()
输出 :
示例 #2:
Python3
# import numpy
import numpy as np
import matplotlib.pyplot as plt
# Using standard_gamma() method
gfg = np.random.standard_gamma(3.47, 5000)
gfg1 = np.random.power(gfg, 5000)
plt.hist(gfg1, bins = 50, density = True)
plt.show()
输出 :