Curriculum
Course: NumPy
Login

Curriculum

NumPy

Text lesson

Exponential Distribution

Exponential distribution describes the time until the next event occurs, such as failure or success. It has two parameters:

  • scale: the inverse of the rate (similar to λ in Poisson distribution), with a default value of 1.0.
  • size: defines the shape of the returned array.

Example

Generate a sample from an exponential distribution with a scale of 2.0, resulting in a 2×3 array.

from numpy import random

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

print(x)

Visualization of Exponential Distribution

Example

from numpy import random
import matplotlib.pyplot as plt
import seaborn as sns

sns.distplot(random.exponential(size=1000), hist=False)

plt.show()

Result

exponential1

Relation Between Poisson and Exponential Distribution

Poisson distribution focuses on the number of occurrences of an event within a specific time period, while exponential distribution describes the time intervals between these events.