summaryrefslogtreecommitdiffhomepage
path: root/doc/hash-birthday-paradox.py
blob: 8fa7ae9210c4f33a5d03993346f39f173587fa79 (plain)
1
2
3
4
5
6
7
8
9
10
11
#!/usr/bin/env python
import math
N = 2**16
probUnique = 1.0
for k in range(1, 10_000):
    val = 1 - math.exp(-0.5 * k * (k - 1) / N)
    # probAllUnique = probUnique * (N - (k - 1)) / N
    #print(k, 1 - probAllUnique, val)
    print(k, val)
    if val + 1e-12 > 1:
        break