Skip to content

Instantly share code, notes, and snippets.

@galenseilis
Last active October 16, 2022 00:45
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 galenseilis/86310855b530d0deb5440798d4863724 to your computer and use it in GitHub Desktop.
Save galenseilis/86310855b530d0deb5440798d4863724 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import binom
n, p = 100, 0.5
x = np.arange(n)
fig, ax = plt.subplots(1, 1)
ax.plot(x, binom.pmf(x, n, p), 'bo', ms=1, label='binom pmf')
ax.vlines(x, 0, binom.pmf(x, n, p), colors='b', lw=1, alpha=0.5)
plt.title(f'binomial(52 | {n}, {p}) = {binom.pmf(52, n, p)}')
plt.xlabel('n')
plt.ylabel('$\\operatorname{binomial}\\left(n|100,\\frac{1}{2}\\right)$')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment