Skip to content

Instantly share code, notes, and snippets.

View arieroos's full-sized avatar
📖
Colossians 3:23

Arie Roos arieroos

📖
Colossians 3:23
  • Pretoria, South Africa
  • 16:32 (UTC +02:00)
View GitHub Profile
@zadam
zadam / collision.py
Created October 28, 2017 15:25
Calculate birthday paradox (chance of collision) for very large numbers
#!/usr/bin/python
# This is used for calculating of birthday paradox for large values
# We're using approximation explained here: http://preshing.com/20110504/hash-collision-probabilities/
# Beware that approximation isn't very precise at smaller params N and K, but gets more precise with large numbers
# see https://docs.python.org/3/library/decimal.html#module-decimal
from decimal import *
# setting decimal precision