Skip to content

Instantly share code, notes, and snippets.

@sergeymong
Created January 5, 2021 14:16
Show Gist options
  • Save sergeymong/84937a804ee50d8c9c7ff36e31d7a24f to your computer and use it in GitHub Desktop.
Save sergeymong/84937a804ee50d8c9c7ff36e31d7a24f to your computer and use it in GitHub Desktop.
[PMF] Probability Mass Function #Python #Matplotlib #Numpy #Statistics
def plot_pmf(data, ylabel='pmf', xlabel='defaults'):
# Compute bin edges: bins
bins = np.arange(min(data), max(data) + 1.5) - 0.5
# Generate histogram
_ = plt.hist(data, bins=bins, normed=True)
# Label axes
_ = plt.ylabel(ylabel)
_ = plt.xlabel(xlabel)
# Show the plot
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment