Last active
February 1, 2020 08:27
-
-
Save whiledoing/73295f44df3e894c9b89b7322aaa4620 to your computer and use it in GitHub Desktop.
[scipy-snippets] scipy snippets #python #scipy
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
# from: https://nbviewer.jupyter.org/github/CamDavidsonPilon/Probabilistic-Programming-and-Bayesian-Methods-for-Hackers/blob/master/Chapter1_Introduction/Ch1_Introduction_PyMC3.ipynb | |
import scipy.stats as stats | |
from matplotlib import pyplot as plt | |
import numpy as np | |
a = np.linspace(0, 4, 100) | |
expo = stats.expon | |
lambda_ = [0.5, 1] | |
for l, c in zip(lambda_, colours): | |
plt.plot(a, expo.pdf(a, scale=1./l), lw=3, | |
color=c, label="$\lambda = %.1f$" % l) | |
plt.fill_between(a, expo.pdf(a, scale=1./l), color=c, alpha=.33) | |
plt.legend() | |
plt.ylabel("PDF at $z$") | |
plt.xlabel("$z$") | |
plt.ylim(0,1.2) | |
plt.title("Probability density function of an Exponential random variable;\ | |
differing $\lambda$"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment