import numpy as np
import matplotlib.pyplot as plt
import scipy as sp

Examples from webpage

# 1
X = sp.stats.expon(scale = 5000)
# 1a
X.cdf(2500)
0.3934693402873666
# 1b
1 - X.cdf(6000)
0.3011942119122022
#2
X = sp.stats.expon(scale = 5000)
# 2a
1 - X.cdf(7000)
0.24659696394160646
# 2b
t = X.ppf(0.1)
X.cdf(t)
0.10000000000000002
# can we plot the ppf function?
p = np.linspace(1e-5, 1 - 1e-5, 100)
plt.plot(p, X.ppf(p));

# can we plot the CDF?
x = np.linspace(1e-5, 50000, 100)
plt.plot(x, X.cdf(x));

# How long will it take for the 
# longest lasting 10% of capacitors
# to fail?
X.ppf(.9)
11512.925464970229
# What is the probability that a 
# capacitor will last between 2000 and
# 6000 hours?
X.cdf(6000) - X.cdf(2000)
0.36912583412343714