Bootstrap 95% CI for the mean of a binary array. Returns (lo%, hi%).
(arr: np.ndarray, rng: np.random.Generator)
| 93 | |
| 94 | |
| 95 | def bootstrap_ci(arr: np.ndarray, rng: np.random.Generator) -> tuple[float, float]: |
| 96 | """Bootstrap 95% CI for the mean of a binary array. Returns (lo%, hi%).""" |
| 97 | n = len(arr) |
| 98 | idx = rng.integers(0, n, size=(BOOTSTRAP_N, n)) |
| 99 | means = arr[idx].mean(axis=1) |
| 100 | lo, hi = np.percentile(means, [2.5, 97.5]) |
| 101 | return 100 * lo, 100 * hi |
| 102 | |
| 103 | |
| 104 | def paired_bootstrap( |