Exponential Distribution

M.Ramya

 Exponential Distribution in Python

The Exponential Distribution is commonly used to model the time between events in a process where events occur continuously and independently at a constant average rate. It’s widely applied in scenarios such as:

  • Time until failure of a machine component
  • Time until the next customer arrives
  • Time between phone calls at a call center

Parameters of Exponential Distribution:

  • scale: The inverse of the rate parameter (λ) from the Poisson distribution. It defines the average time between events. The default value is 1.0.
  • size: Specifies the output shape of the returned sample (i.e., the number of random values you want to generate).

Program:

 Generating Samples

Let’s generate random numbers following an exponential distribution with:

  • scale = 2.0
  • size = (2, 3) (i.e., a 2x3 matrix)

from numpy import random

x = random.exponential(scale=2, size=(2, 3))

print(x)

Output:

[[0.55267412 0.48985355 1.48196931]
 [3.16271856 0.71002355 1.13254062]]

Visualizing Exponential Distribution

We can also visualize the exponential distribution using Seaborn and Matplotlib:

Program:

from numpy import random

import matplotlib.pyplot as plt

import seaborn as sns

sns.displot(random.exponential(size=1000), kind="kde")

plt.title("Exponential Distribution")

plt.show()

Relation Between Poisson and Exponential Distributions

  • Poisson Distribution: Focuses on the number of events occurring within a fixed time period.
  • Exponential Distribution: Focuses on the time between consecutive events.


Tags
Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send