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
""" | |
Generalizable form of the "birthday problem" | |
https://en.wikipedia.org/wiki/Birthday_problem | |
This can be used to get an idea of the viability of hash function. | |
e.g. if a hash function results in a hash that can be represented by 8 hex | |
digits (16^8 = 4,294,967,296 possible hash values) and you expect to be hashing | |
100,000 values, you can use "100,000" as the "n" value and "4,294,967,296" | |
as the "m" value to get the probability of hash collisions: |