#290·AI-Trader

bootstrap_ci does not resample, so most reported intervals have zero width

Author: LudwigJMarxCreated Sep 21, 2026Updated Sep 21, 2026

Summary

bootstrap_ci builds each "sample" as values[(offset + i * 7) % n] for i in range(n). When gcd(7, n) == 1 that is a permutation of the input, so every estimate equals the sample mean and the interval collapses to [mean, mean]. When n is a multiple of 7 the expression visits one index repeatedly, so the interval is a quantile over the raw values rather than over the mean. Neither case draws with replacement.

Where

research/scripts/research_common.py:139-149

python
for offset in range(max(50, min(500, n * 20))):
    sample = [values[(offset + i * 7) % n] for i in range(n)]
    estimates.append(mean(sample))
return quantile(estimates, 0.025), quantile(estimates, 0.975)

Used by analyze_experiments.effect_row for ci_low/ci_high in all five output tables, and by research_common.variant_summary for challenge_return_by_variant.csv.

Environment

Commit d03ff6c
Python 3.14.7
OS macOS 26.6.2, arm64

Reproduction

python
from research_common import bootstrap_ci, mean

for values in ([1.0, 9.0], [1.0, 2.0, 3.0, 100.0], [0.0, 10.0, 20.0, 30.0, 40.0],
               list(range(1, 8)), [float(v) for v in range(1, 15)],
               [float(v) for v in range(1, 21)]):
    lo, hi = bootstrap_ci(values)
    print(len(values), math.gcd(7, len(values)), mean(values), lo, hi, hi - lo)
  n  gcd(7,n)        mean      ci_low     ci_high       width
  2         1      5.0000      5.0000      5.0000      0.0000
  4         1     26.5000     26.5000     26.5000      0.0000
  5         1     20.0000     20.0000     20.0000      0.0000
  7         7      4.0000      1.0000      7.0000      6.0000
 14         7      7.5000      4.5000     10.5000      6.0000
 20         1     10.5000     10.5000     10.5000      0.0000

The index sequence for n = 4:

offset=0: indices=[0, 3, 2, 1] sample=[1.0, 100.0, 3.0, 2.0] mean=26.5
offset=1: indices=[1, 0, 3, 2] sample=[2.0, 1.0, 100.0, 3.0] mean=26.5
offset=2: indices=[2, 1, 0, 3] sample=[3.0, 2.0, 1.0, 100.0] mean=26.5

For n = 7 and n = 14 the reported interval spans the raw values (1 to 7, and 4.5 to 10.5), which is a spread of the data, not of the estimate.

Note on the comment

The comment on line 142 says "Deterministic light-weight bootstrap by rotating samples rather than relying on a random seed". Determinism is available with a fixed seed and resampling with replacement, for example random.Random(0).choices(values, k=n), which keeps the result reproducible.

Not verified

  • No check against a reference implementation; the claim is about what the code computes, not about which interval is correct.
  • Not run against real export data, only against the literal inputs above.