Created
January 31, 2016 16:21
-
-
Save walterreade/b8eea917a5066a45c6b9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from scipy import exp, log | |
from scipy.special import gammaln | |
def prob_unique(N, r): | |
""" If you have a set of N things to choose from, and take r samples, | |
the probability that all r samples are unique. | |
http://www.johndcook.com/blog/2016/01/30/general-birthday-problem | |
""" | |
return exp( gammaln(N+1) - gammaln(N-r+1) - r*log(N) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment