import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,
AutoMinorLocator)
from scipy.stats import expon
%matplotlib inline
plt.xkcd()
_, ax = plt.subplots(figsize=(12,8))
# seme Exponential parameters
lambdas = [2.0, 1.5, 1.0, 0.5]
# qualitative color scheme
colors = ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3']
x = np.linspace(0, 4, 500)
for i,l in enumerate(lambdas):
pdf = expon.pdf(x, scale=1/l)
ax.plot(x, pdf, color=colors[i], lw=3.2, label=r'$\lambda = {}$'.format(l))
# legend styling
legend = ax.legend()
for label in legend.get_texts():
label.set_fontsize('large')
for label in legend.get_lines():
label.set_linewidth(1.5)
# y-axis
ax.set_ylim([-0.01, 2.0])
ax.set_ylabel(r'$f(x)$')
ax.set_yticks(np.arange(0,2.1,.2))
# x-axis
ax.set_xlim([0.0, 3.0])
ax.set_xlabel(r'$x$')
# x-axis tick formatting
majorLocator = MultipleLocator(1)
majorFormatter = FormatStrFormatter('%d')
minorLocator = MultipleLocator(1)
ax.xaxis.set_major_locator(majorLocator)
ax.xaxis.set_major_formatter(majorFormatter)
ax.xaxis.set_minor_locator(minorLocator)
ax.grid(color='grey', linestyle='-', linewidth=0.3)
plt.suptitle(r'Exponential PDF: $f(x) = \lambda e^{-\lambda x}$ for $x \geq 0$')
plt.show()
If we let Y=λX, then Y∼Expo(1).
You can compare this with the standardized Normal.
Proof
P(Y≤y)=P(X≤yλ)=1−e−λyλ just plugging yλ into the CDF above=1−e−y which is the CDF of Expo(1) ◼We will next find the mean and variance of Expo(1), and then derive the general case mean and variance afterwards.
Let Y∼Expo(1), find E(Y) and Var(Y).
E(Y)=∫∞0ye−ydy let u=y, du=dy and let dv=e−ydy, v=−e−y=−yey|∞0⏟evaluates to 0+∫∞0e−ydy⏟PDF of Expo(1)=1Var(Y)=E(Y2)−EY2=∫∞0y2e−ydy−12 let u=y2, du=2ydy and let dv=e−ydy, v=−e−y=−y2ey|∞0+∫∞02ye−ydy−1=0+2−1=1We can derive the mean and variance of Expo(λ) from that of Expo(1).
From Y=λX we have X=yλ.
E(X)=E(Yλ)=1λE(Y)=1λVar(X)=Var(Yλ)=1λ2Var(Y)=1λ2If you have a random variable representing a wait-time (continuous), the memorylessness property means that no matter how long you have already waited, the probability that you will have to wait an additional time t is the same as if you were starting fresh from 0 (irrespective of the time you already spent waiting).
Fact: Expo(λ) is the only distribution with the memorylessness property.
P(X≥s+t|X≥s)=P(X≥t)The survival function is the random variable that describes how long something might live/exist, in constrast to that for a waiting time. In other words, P(X≥s) is the probability that some object of interest lasts longer than a continuous time s.
P(X≥s)=1−P(X≤s)=1−(1−e−λs)=e−λs the survival functionAnd so using this survival function in an equation using the definition of conditional probability, we have:
P(X≥s+t|X≥s)=P(X≥s+t, X≥s)P(X≥s)=P(X≥s+t)P(X≥s) since P(X≥s) is redundant=e−λ(s+t)e−λs ratio of survival functions=e−λt=P(X≥t)◼This is a brief introduction to conditional expectation, which is just like conditional probability.
Given X∼Expo(λ), what is the expected wait-time if we have already waited for some time a?
E(X|X>a)=a+E(X−a|X>a) by linearity=a+1λ by the memorylessness propertyView Lecture 16: Exponential Distribution | Statistics 110 on YouTube.