Enumerate a tiny paired randomization test
A paired randomization test asks how surprising the observed mean difference would be if either model could exchange its outcome on each case. For a small independent paired sample, enumerate every sign assignment instead of relying on simulation.
The two-sided statistic uses the absolute mean, and ties count as at least as extreme. Exchangeability under the null is an assumption, not a property guaranteed by arithmetic. The exact enumerator is intentionally bounded to twelve cases because its cost doubles with each additional case. Large or dependent experiments need a different sampling and analysis design.
import itertools
values=[1,2]
null=[sum(s*x for s,x in zip(signs,values)) for signs in itertools.product((-1,1),repeat=2)]
print(null)Review the design
Exact enumeration removes Monte Carlo error, not modeling assumptions. A small p-value does not measure effect size or the probability that a production release will improve user outcomes.
Your task
Implement sign_flip_p(differences) for 1..12 finite values. Enumerate all sign combinations and return the fraction with absolute summed difference >= the observed absolute sum, with 1e-12 tie tolerance.
The explanation opens here once every check passes.