@@ -124,7 +124,7 @@ def _get_tarp_coverage_single(
124
124
f = np .sum ((samples_distances < theta_distances ), axis = 0 ) / num_samples
125
125
126
126
# Compute expected coverage
127
- h , alpha = np .histogram (f , density = True , bins = num_alpha_bins )
127
+ h , alpha = np .histogram (f , density = True , bins = num_alpha_bins , range = ( 0 , 1 ) )
128
128
dx = alpha [1 ] - alpha [0 ]
129
129
ecp = np .cumsum (h ) * dx
130
130
return np .concatenate ([[0 ], ecp ]), alpha
@@ -168,15 +168,14 @@ def _get_tarp_coverage_bootstrap(samples: np.ndarray,
168
168
169
169
boot_ecp = np .empty (shape = (num_bootstrap , num_alpha_bins + 1 ))
170
170
for i in tqdm (range (num_bootstrap )):
171
- idx_remove = np .random .randint (num_sims )
172
- idx_add = np .random .randint (num_sims )
173
-
174
- # Replacing one simulation and its samples by another and its associated samples
175
- samples [:, idx_remove , :] = samples [:, idx_add , :]
176
- theta [idx_remove , :] = theta [idx_add , :]
177
-
178
- boot_ecp [i , :], alpha = _get_tarp_coverage_single (samples ,
179
- theta ,
171
+ idx = np .random .randint (low = 0 , high = num_sims , size = num_sims )
172
+
173
+ # Sample with replacement from the full set of simulations
174
+ boot_samples = samples [:, idx , :]
175
+ boot_theta = theta [idx , :]
176
+
177
+ boot_ecp [i , :], alpha = _get_tarp_coverage_single (boot_samples ,
178
+ boot_theta ,
180
179
references = references ,
181
180
metric = metric ,
182
181
num_alpha_bins = num_alpha_bins ,
0 commit comments