Full name
random.weibullvariate
Library
random
Syntax
random.weibullvariate(alpha, beta)
Description
The random.weibullvariate function returns a random number drawn from a Weibull distribution .
Parameters
- alpha: α parameter of the distribution.
- beta: β parameter of the distribution.
Result
The random.weibullvariate function returns a real number.
Examples
We can generate a random number extracted from a Weibull distribution with α equal to 1 and β equal to 1.5 with the following code:
random.weibullvariate(1, 1.5)
0.095424751576311
To confirm the distribution from which the random numbers are extracted we can generate one hundred thousand random numbers from a Weibull distribution with α equal to 1 and β equal to 1.5 and show its histogram:
import matplotlib.pyplot as plt
plt.figure(figsize = (8, 4))
plt.hist([random.weibullvariate(1, 1.5) for i in range(100000)], bins = 100)
plt.grid()
plt.show()
plt.hist([random.weibullvariate(1, 1.5) for i in range(100000)], bins = 100)
plt.grid()
plt.show()