LA ILAHA ILLA HU
Allah, Your Lord There Is No Deity Except Him.
Python Data Science NumPy Random Exponential Data Distribution
Exponential Distribution: is used for describing time till next event e.g. failure/success etc.
It has the following two parameters.
1. scale - inverse of rate ( see lam in poisson distribution ) defaults to 1.0.
2. size - The shape of the returned array.
Example 1: Draw out a sample for exponential distribution with 2.0 scale with 2x4 size.
Code
from numpy import random
x = random.exponential(scale=2, size=(2, 4))
print(x)
the output will be
[[2.25692663 0.10811811 0.03751409 4.24780845]
[0.49943354 1.11501134 1.49241455 0.2187935 ]]
Note: Every time the code is run the output may vary because of random generation.
Visualization of Exponential Distribution
Example 2
Code
from numpy import random
import matplotlib.pyplot as plt
import seaborn as sns
sns.distplot(random.
exponential(size=100000), hist=False)
plt.show()
the output will be