Skip to content

Instantly share code, notes, and snippets.

@JohnDeJesus22
Created October 28, 2019 02:04
Show Gist options
  • Save JohnDeJesus22/11189c622902619cb418aee530a1219c to your computer and use it in GitHub Desktop.
Save JohnDeJesus22/11189c622902619cb418aee530a1219c to your computer and use it in GitHub Desktop.
HgPMF
def hypergeom_plot(N, A, n):
'''
Visualization of Hypergeometric Distribution for given parameters
:param N: population size
:param A: total number of desired items in N
:param n: number of draws made from N
:returns: Plot of Hypergeometric Distribution for given parameters
'''
x = np.arange(0, n+1)
y = [hypergeom_pmf(N, A, n, x) for x in range(n+1)]
plt.plot(x, y, 'bo')
plt.vlines(x, 0, y, lw=2)
plt.xlabel('# of desired items in our draw')
plt.ylabel('Probablities')
plt.title('Hypergeometric Distribution Plot')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment