random.weibullvariate
function . weibullvariate()
is an inbuilt method of the random
module. It is used to return a random floating point number with Weibull distribution.random.weibullvariate(alpha,beta)
Parameter | Description |
---|---|
alpha | Required. It is a shape parameter. |
beta | Required. It is a shape parameter. |
Example :
1.
# import the random moduleimport random# determining the values of the parametersalpha = 1beta = 1.5# using the weibullvariate() methodprint(random.weibullvariate(alpha,beta))
# import the required librariesimport randomimport matplotlib.pyplot as plt# store the random numbers in a# listnums = []alpha = 1beta = 1.5for i in range(100):temp = random.weibullvariate(alpha, beta)nums.append(temp)# plotting a graphplt.plot(nums)plt.show()
Output :
# import the required librariesimport randomimport matplotlib.pyplot as plt# store the random numbers in a listnums = []alpha = 1beta = 1.5for i in range(10000):temp = random.weibullvariate(alpha, beta)nums.append(temp)# plotting a graphplt.hist(nums, bins = 200)plt.show()
Output :
Comments