diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-06-10 00:21:08 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-06-30 21:52:02 +0200 |
commit | 86c06037da81f1033a3a36a3523d8d21d1f34ead (patch) | |
tree | ae56d4ab889e4524038029ad9ccd3020fc9226cb /doc | |
parent | 014fc7ab7762890c44ad3885668696300ceed25e (diff) |
doc++
Diffstat (limited to 'doc')
-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 |