Exponential Distribution
Published Mar 3, 2025
Contribute to Docs
The exponential distribution models the time between independent events that occur at a fixed average rate. It is frequently used in reliability analysis, queuing theory, and survival analysis. The distribution is defined by a single parameter, the rate λ which determines how quickly events occur.
The exponential distribution formula is given by:
$$f(x|λ) = λ e^{-λ x}$$
λ
: The rate parameter that represents the number of events per unit time.x
: A random variable that represents the time between events.
Example
The example below demonstrates how to generate random samples from an exponential distribution using NumPy and visualize the results with a histogram using Matplotlib:
import numpy as npimport matplotlib.pyplot as plt# Set the rate parameter (lambda)rate = 1.5 # Events per unit time# Generate 1,000 random samples from the exponential distributiondata = np.random.exponential(scale=1/rate, size=1000)# Plot the histogram of the generated dataplt.hist(data, bins=30, density=True, alpha=0.6, color='teal', edgecolor='black')plt.title(f"Exponential Distribution (rate = {rate})")plt.xlabel("Time Between Events")plt.ylabel("Density")plt.show()
The above code produces the following output:
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.