4 ms·
I use the Taylor series approximation. Take your desired probability, say one-in-a-million prob = 0.999999 And calculate the bitspace. In this case, 12 ba
by aristus 3y ago
I use the Taylor series approximation.
Take your desired probability, say one-in-a-million
prob = 0.999999
And calculate the bitspace. In this case, 12 base-62 digits
space = 62 ** 12
Take the natural log of the probability, times -2, times the bitspace. The sqrt of that is approximately the number of items that can be shoved into the bitspace before there is a one-in-a-million chance of collision.
int(math.sqrt((-2 * math.log(prob)) * space))
--> 80327683
With 80 million items, the odds of a collision are still 10*6 to 1 against.