Created
January 5, 2021 14:16
-
-
Save sergeymong/84937a804ee50d8c9c7ff36e31d7a24f to your computer and use it in GitHub Desktop.
[PMF] Probability Mass Function #Python #Matplotlib #Numpy #Statistics
This file contains 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
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