diff options
-rw-r--r-- | doc/hash-birthday-paradox.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/hash-birthday-paradox.py b/doc/hash-birthday-paradox.py new file mode 100644 index 00000000..8fa7ae92 --- /dev/null +++ b/doc/hash-birthday-paradox.py @@ -0,0 +1,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 |