weibull分布代码
时间: 2023-07-23 16:57:20 浏览: 155
Sure, here is an example of how to generate random numbers from a Weibull distribution in Python using the scipy library:
```python
from scipy.stats import weibull_min
import numpy as np
# Define the shape and scale parameters
shape = 2.5
scale = 1.0
# Create a Weibull distribution object
weibull_dist = weibull_min(shape, scale=scale)
# Generate random numbers from the distribution
random_numbers = weibull_dist.rvs(size=10)
# Print the generated random numbers
print(random_numbers)
```
In this example, we use the `weibull_min` class from the `scipy.stats` module to create a Weibull distribution object. We specify the shape parameter and the scale parameter of the distribution. The `rvs` method is then used to generate random numbers from the distribution, with the `size` argument determining the number of random numbers to generate. Finally, we print the generated random numbers.
阅读全文