Skip to content

Instantly share code, notes, and snippets.

@JohnDeJesus22
Created October 28, 2019 01:56
Show Gist options
  • Save JohnDeJesus22/cf58071333cc4c62c387fc859437b1af to your computer and use it in GitHub Desktop.
Save JohnDeJesus22/cf58071333cc4c62c387fc859437b1af to your computer and use it in GitHub Desktop.
HgCDF
def hypergeom_cdf(N, A, n, t, min_value=None):
'''
Cumulative Density Funtion 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 t: number of desired items in our draw of n items up to t
:returns: CDF computed up to t
'''
if min_value:
return np.sum([hypergeom_pmf(N, A, n, x) for x in range(min_value, t+1)])
return np.sum([hypergeom_pmf(N, A, n, x) for x in range(t+1)])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment