PythiloLesson 8 of 12 · progress kept in this browser

Resample paired model differences with a local RNG

Two models evaluated on the same cases produce paired measurements. Resampling their scores independently discards that pairing and changes the uncertainty question. Resample case indices once per replicate and compute the mean of paired differences.

This exercise takes precomputed per-case differences, a local random seed and an explicit nearest-rank quantile rule. It does not modify the process-global random generator. The percentile bootstrap has limitations for small or dependent samples; user-level or time-block resampling is needed when rows are not independent. Fix the analysis plan before comparing many candidate models.

import random
rng=random.Random(4)
differences=[1,-1,2]
print([rng.choice(differences) for _ in range(3)])
Your task

Implement bootstrap_interval(differences,repeats,seed,alpha=.05). Draw n indices with replacement for each replicate, sort replicate means, and return indices floor((alpha/2)(repeats-1)) and ceil((1-alpha/2)(repeats-1)). Require nonempty finite data, repeats>=2, and 0<alpha<1.