Skip to content

Instantly share code, notes, and snippets.

@whiledoing
Last active February 1, 2020 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whiledoing/73295f44df3e894c9b89b7322aaa4620 to your computer and use it in GitHub Desktop.
Save whiledoing/73295f44df3e894c9b89b7322aaa4620 to your computer and use it in GitHub Desktop.
[scipy-snippets] scipy snippets #python #scipy
# 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