Created
October 28, 2019 01:40
-
-
Save JohnDeJesus22/938cbe1de15792d2304925753929f394 to your computer and use it in GitHub Desktop.
Hypergeometric PMF
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
import numpy as np | |
import matplotlib.pyplot as plt | |
from scipy.special import comb | |
def hypergeom_pmf(N, A, n, x): | |
''' | |
Probability Mass Function for Hypergeometric Distribution | |
:param N: population size | |
:param A: total number of desired items in N | |
:param n: number of draws made from N | |
:param x: number of desired items in our draw of n items | |
:returns: PMF computed at x | |
''' | |
Achoosex = comb(A,x) | |
NAchoosenx = comb(N-A, n-x) | |
Nchoosen = comb(N,n) | |
return (Achoosex)*NAchoosenx/Nchoosen |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment