Probabilistic Data Structures: Bloom Filters & Beyond
Probabilistic data structures for approximate set membership, counting, and cardinality estimation: Bloom filters, Count-Min Sketch, HyperLogLog, and Cuckoo filters.
Probabilistic data structures for approximate set membership, counting, and cardinality estimation: Bloom filters, Count-Min Sketch, HyperLogLog, and Cuckoo filters.
| Name | Type | Space usage | False positive rate | Operations | Strengths | Weaknesses | Use cases | Notes | Relative error |
|---|---|---|---|---|---|---|---|---|---|
| Bloom Filter | Membership | m bits for m-bit array | ~ (1 - e^{-kn/m})^k where k = hash count, n = elements, m = bits |
|
|
|
| Optimal hash count k = (m/n) * ln(2). A 10-bit-per-element filter has ~1% false positive rate. | null |
| Counting Bloom Filter | Membership with Deletion | m × d bits (d = counter width, typically 4 bits) | Same as standard Bloom Filter |
|
|
|
| Use 4-bit counters (max 15 increments) to balance memory and overflow risk. Larger d for high-frequency items. | null |
| Cuckoo Filter | Membership | ~ 1.17 bytes per element (for 3% FPR, β = 95% load) | Configurable (typically 1-5%) |
|
|
|
| Uses cuckoo hashing with two hash functions. When bucket full, existing item is kicked to alternate location. | null |
| HyperLogLog | Cardinality Estimation | ~ 1.5 KB for 2^14 registers (standard), error ~ 1.04/√m | null |
|
|
|
| Presto, Redshift, BigQuery, and Redis all implement HyperLogLog natively. Practical limit: trillions of distinct values. | ~ 1.04/√m (e.g., 1.5KB → ~2% error for billions) |
| Count-Min Sketch | Frequency Estimation | d × w counters (d = depth, w = width). Typically d=5, w = 2/ε | null |
|
|
|
| Used by Apache DataSketches, Redis (top-k), and network monitoring tools. Set d = ceil(ln(1/δ)), w = ceil(2/ε). | Overestimates frequency with probability δ for error bound ε |
| MinHash | Similarity Estimation | k × 64 bits (k = number of hash functions, typically 128-256) | null |
|
|
|
| Foundation for many LSH (Locality-Sensitive Hashing) schemes. Google, Amazon, and Netflix use variants for dedup and recommendations. | ~ 1/√k for Jaccard similarity (e.g., k=256 → ~6% error) |
The static files are identical to what the API returns, but with no rate limit and no server round trip. Use the API when you want a query and a content type; use the files when you want to cache one document.
curl "https://yjtoon.com/api/dataset/bloom-filters-probabilistic?format=toon"
const res = await fetch( "https://yjtoon.com/static-data/dataset/bloom-filters-probabilistic.toon" ); const toon = await res.text();
Rate limit: 120 requests per minute per IP, no key and no signup. API reference →