Hash Collision Probability: From the Birthday Paradox to Approximations

2025-06-25
Hash Collision Probability: From the Birthday Paradox to Approximations

This article delves into the probability of hash collisions. Hash functions map arbitrarily complex inputs to single numbers, but there's a risk of hash collisions (different inputs mapping to the same number). Starting with the Birthday Paradox, the article explains the exact formula for calculating hash collision probability and three approximation methods: exponential approximation, simplified approximation, and a further simplified approximation. Through comparison, the exponential approximation performs best in most cases, while the other two are more suitable for quick estimations. The article also provides mathematical proofs supporting the approximation methods.

Read more
Development birthday paradox

Livecoding Graphics in Common Lisp: Building a Boids Program Without Restarts

2025-04-23
Livecoding Graphics in Common Lisp: Building a Boids Program Without Restarts

This article demonstrates livecoding in Common Lisp for graphics programming, using the Boids algorithm as an example. Common Lisp's powerful recompilation feature allows code modification and immediate effect while the program is running, eliminating the need for restarts. The author utilizes the Sketch graphics framework, incrementally implementing the Boids algorithm and showcasing the efficient development process enabled by livecoding. By modifying code and observing the real-time effects, the core Boids algorithm—including separation, cohesion, and alignment rules—is implemented, culminating in a mouse-following Boids simulation. Livecoding significantly enhances development efficiency and interactivity.

Read more