Created
September 19, 2019 15:50
-
-
Save igorrs/7155f710d51f5e7a156fd8558113824e to your computer and use it in GitHub Desktop.
Probability of collision after generating k random base-32 numbers with x digits
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
def probability_of_collision(k, x) | |
total_numbers = 32**x | |
1 - Math::E**(((k-1)*-k) / (2.0*total_numbers)) | |
end | |
# Example | |
probability_of_collision(100000, 8) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment