Weibull Distribution
Published Mar 4, 2025
Contribute to Docs
The Weibull distribution is a flexible continuous probability distribution commonly used to model the time until an event occurs, such as equipment failure or life expectancy. The shape of the distribution is controlled by its parameters, allowing it to represent different types of failure rates. It is widely applied in reliability engineering, survival analysis, and risk assessment.
Example
The example below generates random samples from a Weibull distribution using NumPy and visualizes the results with a histogram. This demonstration illustrates how the data conforms to the Weibull distribution’s characteristics.
import numpy as npimport matplotlib.pyplot as plt# Set the shape parameter for the Weibull distributionshape = 2.0# Generate 1,000 random samples from the Weibull distributiondata = np.random.weibull(shape, 1000)# Plot the histogram of the generated dataplt.hist(data, bins=30, density=True, alpha=0.6, color='purple', edgecolor='black')plt.title(f"Weibull Distribution (shape={shape})")plt.xlabel("Value")plt.ylabel("Density")plt.show()
The above code will generate a histogram representing the Weibull distribution:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Data Science on Codecademy
- Career path
Data Scientist: Machine Learning Specialist
Machine Learning Data Scientists solve problems at scale, make predictions, find patterns, and more! They use Python, SQL, and algorithms.Includes 27 CoursesWith Professional CertificationBeginner Friendly95 hours - Course
Learn Python 3
Learn the basics of Python 3.12, one of the most powerful, versatile, and in-demand programming languages today.With CertificateBeginner Friendly23 hours