Created
December 1, 2022 12:10
-
-
Save maxdevblock/9b0605d9e7debef6fbb124f80ba9259e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy.stats as sps | |
import matplotlib.pyplot as plt | |
tau = 5 | |
beta = 1/tau | |
alpha = 5 | |
d = sps.gamma(a=alpha, scale=1/beta) | |
x = np.linspace(0, d.ppf(.999), 1000) | |
y = d.pdf(x) | |
P = d.cdf(15) | |
fig, ax = plt.subplots(facecolor="w") | |
plt.plot(x, y) | |
plt.fill_between( | |
x[x<=15], | |
0, y[x<=15], | |
color="r", alpha=.25 | |
) | |
plt.plot([0, 0], [0, y[0]], "r") | |
plt.plot([15, 15], [0, y[x<=15][-1]], "r") | |
plt.axhline(0, color="k", alpha=.25) | |
plt.xlabel("Wating time $t$") | |
plt.ylabel("Probability Density") | |
plt.text(16, .01, f"$P(T\leq 15)={P*100:.0f}\%$") | |
plt.title(fr"$T \sim \mathrm{{Gamma}}(\alpha={alpha}, \beta={beta})$") | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment