FAILURE MAP
← Case archive

FA-72881 / Probabilistic sketches / Open access

Bloom filter sizing: probe count inverts the bits-per-item ratio · case 01

Filters use a single probe regardless of size, destroying the false-positive guarantee.

Verified by executionVariant 1 · 10 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The optimal probe count uses n/m instead of m/n.

THE FAILURE

The optimal probe count uses n/m instead of m/n.

Unsuccessful approach: Dividing by ln 2 instead of multiplying overshoots the optimal probe count by a factor of about two.

Case contract

Input {n, p}. Reject n <= 0 or p outside the open interval (0,1) with "invalid". Otherwise m = ceil(-n ln p / (ln 2)^2), k = max(1, round(m/n * ln 2)), bytes = ceil(m/8), and the predicted false-positive rate (1 - e^(-k n / m))^k rounded to 6 decimals. Return [m, k, bytes, fp].

Why this case matters

Capacity planning for a Bloom filter decides memory and probe count before any item is inserted; an undersized array silently exceeds the promised false-positive rate.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    n = x['n']
    p = x['p']
    if n <= 0 or not (0 < p < 1):
        return 'invalid'
    m = math.ceil(-n * math.log(p) / (math.log(2) ** 2))
    k = max(1, round(n / m * math.log(2)))
    fp = (1 - math.exp(-k * n / m)) ** k
    return [m, k, (m + 7) // 8, round(fp, 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[['thousand items one percent', {'n': 1007, 'p': 0.01}, [9653, 7, 1207, 0.010035]],
  ['small set loose target', {'n': 4, 'p': 0.3}, [11, 2, 2, 0.267056]],
  ['near-one target clamps probes', {'n': 50, 'p': 0.9}, [11, 1, 2, 0.989385]],
  ['tight target', {'n': 201, 'p': 0.0001}, [3854, 13, 482, 0.0001]],
  ['odd bit count', {'n': 38, 'p': 0.05}, [237, 4, 30, 0.050232]],
  ['medium set', {'n': 17, 'p': 0.02}, [139, 6, 18, 0.019754]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 780, 'p': 0.123}, [3403, 3, 426, 0.122936]],
  ['fractional ceil', {'n': 10, 'p': 0.07}, [56, 4, 7, 0.067896]]],
 [['thousand items one percent', {'n': 1014, 'p': 0.01}, [9720, 7, 1215, 0.010036]],
  ['small set loose target', {'n': 5, 'p': 0.3}, [13, 2, 2, 0.287972]],
  ['near-one target clamps probes', {'n': 100, 'p': 0.9}, [22, 1, 3, 0.989385]],
  ['tight target', {'n': 202, 'p': 0.0001}, [3873, 13, 485, 0.0001]],
  ['odd bit count', {'n': 39, 'p': 0.05}, [244, 4, 31, 0.049785]],
  ['medium set', {'n': 22, 'p': 0.02}, [180, 6, 23, 0.019701]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 783, 'p': 0.123}, [3416, 3, 427, 0.122943]],
  ['fractional ceil', {'n': 11, 'p': 0.07}, [61, 4, 8, 0.069737]]],
 [['thousand items one percent', {'n': 1021, 'p': 0.01}, [9787, 7, 1224, 0.010036]],
  ['small set loose target', {'n': 6, 'p': 0.3}, [16, 2, 2, 0.278397]],
  ['near-one target clamps probes', {'n': 150, 'p': 0.9}, [33, 1, 5, 0.989385]],
  ['tight target', {'n': 203, 'p': 0.0001}, [3892, 13, 487, 0.0001]],
  ['odd bit count', {'n': 40, 'p': 0.05}, [250, 4, 32, 0.049931]],
  ['medium set', {'n': 27, 'p': 0.02}, [220, 6, 28, 0.020034]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 786, 'p': 0.123}, [3429, 3, 429, 0.122949]],
  ['fractional ceil', {'n': 12, 'p': 0.07}, [67, 4, 9, 0.068452]]],
 [['thousand items one percent', {'n': 1028, 'p': 0.01}, [9854, 7, 1232, 0.010037]],
  ['small set loose target', {'n': 7, 'p': 0.3}, [18, 2, 3, 0.29222]],
  ['near-one target clamps probes', {'n': 200, 'p': 0.9}, [44, 1, 6, 0.989385]],
  ['tight target', {'n': 204, 'p': 0.0001}, [3911, 13, 489, 0.0001]],
  ['odd bit count', {'n': 41, 'p': 0.05}, [256, 4, 32, 0.05007]],
  ['medium set', {'n': 32, 'p': 0.02}, [261, 6, 33, 0.019953]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 789, 'p': 0.123}, [3442, 3, 431, 0.122956]],
  ['fractional ceil', {'n': 13, 'p': 0.07}, [72, 4, 9, 0.069978]]],
 [['thousand items one percent', {'n': 1035, 'p': 0.01}, [9921, 7, 1241, 0.010037]],
  ['small set loose target', {'n': 8, 'p': 0.3}, [21, 2, 3, 0.284327]],
  ['near-one target clamps probes', {'n': 250, 'p': 0.9}, [55, 1, 7, 0.989385]],
  ['tight target', {'n': 205, 'p': 0.0001}, [3930, 13, 492, 0.0001]],
  ['odd bit count', {'n': 42, 'p': 0.05}, [262, 4, 33, 0.050203]],
  ['medium set', {'n': 37, 'p': 0.02}, [302, 6, 38, 0.019895]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 792, 'p': 0.123}, [3455, 3, 432, 0.122963]],
  ['fractional ceil', {'n': 14, 'p': 0.07}, [78, 4, 10, 0.068853]]]]
for label, args, expected in cases[N - 1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
thousand items one percent[9653, 1, 1207, 0.099063][9653, 7, 1207, 0.010035]Failed
small set loose target[11, 1, 2, 0.304856][11, 2, 2, 0.267056]Failed
near-one target clamps probes[11, 3, 2, 0.999996][11, 1, 2, 0.989385]Failed
tight target[3854, 1, 482, 0.050817][3854, 13, 482, 0.0001]Failed
odd bit count[237, 1, 30, 0.148144][237, 4, 30, 0.050232]Failed
medium set[139, 1, 18, 0.115119][139, 6, 18, 0.019754]Failed
rejects p equal oneinvalidinvalidPassed
rejects empty setinvalidinvalidPassed
another sizing[3403, 1, 426, 0.204838][3403, 3, 426, 0.122936]Failed
fractional ceil[56, 1, 7, 0.163536][56, 4, 7, 0.067896]Failed

SHA-256 / ba99005f3db8720cf7ff744e2ef1ed29180265f448488c0ef1fdb5c4e1d1e24b

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json
import math
N = 1
observations = []
def solve(x):
    n = x['n']
    p = x['p']
    if n <= 0 or not (0 < p < 1):
        return 'invalid'
    m = math.ceil(-n * math.log(p) / (math.log(2) ** 2))
    k = max(1, round(m / n / math.log(2)))
    fp = (1 - math.exp(-k * n / m)) ** k
    return [m, k, (m + 7) // 8, round(fp, 6)]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[['thousand items one percent', {'n': 1007, 'p': 0.01}, [9653, 7, 1207, 0.010035]],
  ['small set loose target', {'n': 4, 'p': 0.3}, [11, 2, 2, 0.267056]],
  ['near-one target clamps probes', {'n': 50, 'p': 0.9}, [11, 1, 2, 0.989385]],
  ['tight target', {'n': 201, 'p': 0.0001}, [3854, 13, 482, 0.0001]],
  ['odd bit count', {'n': 38, 'p': 0.05}, [237, 4, 30, 0.050232]],
  ['medium set', {'n': 17, 'p': 0.02}, [139, 6, 18, 0.019754]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 780, 'p': 0.123}, [3403, 3, 426, 0.122936]],
  ['fractional ceil', {'n': 10, 'p': 0.07}, [56, 4, 7, 0.067896]]],
 [['thousand items one percent', {'n': 1014, 'p': 0.01}, [9720, 7, 1215, 0.010036]],
  ['small set loose target', {'n': 5, 'p': 0.3}, [13, 2, 2, 0.287972]],
  ['near-one target clamps probes', {'n': 100, 'p': 0.9}, [22, 1, 3, 0.989385]],
  ['tight target', {'n': 202, 'p': 0.0001}, [3873, 13, 485, 0.0001]],
  ['odd bit count', {'n': 39, 'p': 0.05}, [244, 4, 31, 0.049785]],
  ['medium set', {'n': 22, 'p': 0.02}, [180, 6, 23, 0.019701]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 783, 'p': 0.123}, [3416, 3, 427, 0.122943]],
  ['fractional ceil', {'n': 11, 'p': 0.07}, [61, 4, 8, 0.069737]]],
 [['thousand items one percent', {'n': 1021, 'p': 0.01}, [9787, 7, 1224, 0.010036]],
  ['small set loose target', {'n': 6, 'p': 0.3}, [16, 2, 2, 0.278397]],
  ['near-one target clamps probes', {'n': 150, 'p': 0.9}, [33, 1, 5, 0.989385]],
  ['tight target', {'n': 203, 'p': 0.0001}, [3892, 13, 487, 0.0001]],
  ['odd bit count', {'n': 40, 'p': 0.05}, [250, 4, 32, 0.049931]],
  ['medium set', {'n': 27, 'p': 0.02}, [220, 6, 28, 0.020034]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 786, 'p': 0.123}, [3429, 3, 429, 0.122949]],
  ['fractional ceil', {'n': 12, 'p': 0.07}, [67, 4, 9, 0.068452]]],
 [['thousand items one percent', {'n': 1028, 'p': 0.01}, [9854, 7, 1232, 0.010037]],
  ['small set loose target', {'n': 7, 'p': 0.3}, [18, 2, 3, 0.29222]],
  ['near-one target clamps probes', {'n': 200, 'p': 0.9}, [44, 1, 6, 0.989385]],
  ['tight target', {'n': 204, 'p': 0.0001}, [3911, 13, 489, 0.0001]],
  ['odd bit count', {'n': 41, 'p': 0.05}, [256, 4, 32, 0.05007]],
  ['medium set', {'n': 32, 'p': 0.02}, [261, 6, 33, 0.019953]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 789, 'p': 0.123}, [3442, 3, 431, 0.122956]],
  ['fractional ceil', {'n': 13, 'p': 0.07}, [72, 4, 9, 0.069978]]],
 [['thousand items one percent', {'n': 1035, 'p': 0.01}, [9921, 7, 1241, 0.010037]],
  ['small set loose target', {'n': 8, 'p': 0.3}, [21, 2, 3, 0.284327]],
  ['near-one target clamps probes', {'n': 250, 'p': 0.9}, [55, 1, 7, 0.989385]],
  ['tight target', {'n': 205, 'p': 0.0001}, [3930, 13, 492, 0.0001]],
  ['odd bit count', {'n': 42, 'p': 0.05}, [262, 4, 33, 0.050203]],
  ['medium set', {'n': 37, 'p': 0.02}, [302, 6, 38, 0.019895]],
  ['rejects p equal one', {'n': 10, 'p': 1.0}, 'invalid'],
  ['rejects empty set', {'n': 0, 'p': 0.01}, 'invalid'],
  ['another sizing', {'n': 792, 'p': 0.123}, [3455, 3, 432, 0.122963]],
  ['fractional ceil', {'n': 14, 'p': 0.07}, [78, 4, 10, 0.068853]]]]
for label, args, expected in cases[N - 1]:
    check(label, solve(args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
thousand items one percent[9653, 14, 1207, 0.024778][9653, 7, 1207, 0.010035]Failed
small set loose target[11, 4, 2, 0.345171][11, 2, 2, 0.267056]Failed
near-one target clamps probes[11, 1, 2, 0.989385][11, 1, 2, 0.989385]Passed
tight target[3854, 28, 482, 0.000613][3854, 13, 482, 0.0001]Failed
odd bit count[237, 9, 30, 0.088465][237, 4, 30, 0.050232]Failed
medium set[139, 12, 18, 0.043121][139, 6, 18, 0.019754]Failed
rejects p equal oneinvalidinvalidPassed
rejects empty setinvalidinvalidPassed
another sizing[3403, 6, 426, 0.174064][3403, 3, 426, 0.122936]Failed
fractional ceil[56, 8, 7, 0.111713][56, 4, 7, 0.067896]Failed

SHA-256 / 724db74cf7843642bec701a95b4eac9177b7a50be479d179bafda927bc6259e5

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 10 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

A deterministic, bounded teaching model with stipulated constants and pre-hashed or explicitly hashed inputs; it is not a production implementation and makes no claim of conformance to any library or paper beyond the stated contract. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:48:42.568087+00:00.

Case digest / e1ed7074bba8a63fd4196516ec098707c8e8e42eb736a92cb44b5f3f18785508