Skip to content

Commit 9de531d

Browse files
committed
Fix: Theoretically exact IID (#63)
Earlier IID bounded the error by (\epsilon + \delta). Modified it to now bound it by (\delta) as required.
1 parent 6018a86 commit 9de531d

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

vcache/vcache_policy/strategies/benchmark_iid_verified.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -497,12 +497,14 @@ def select_action(
497497
negative_samples = similarities[labels==0].reshape(-1,1,1)
498498
labels = labels.reshape(-1,1,1)
499499
tholds = self.thold_grid.reshape(1,-1,1)
500-
epsilon = self.epsilon_grid.reshape(1,1,-1)
500+
deltap = self.delta * (num_negative_samples + num_positive_samples)/num_negative_samples
501+
502+
epsilon = self.epsilon_grid[self.epsilon_grid < deltap].reshape(1,1,-1)
501503

502504
cdf_estimate = np.sum(negative_samples < tholds, axis=0, keepdims=True) / num_negative_samples # (1, tholds, 1)
503505
cdf_ci_lower, cdf_ci_upper = self.wilson_proportion_ci(cdf_estimate, num_negative_samples, confidence=1-epsilon) # (1, tholds, epsilon)
504506

505-
pc_adjusted = (1 - self.delta * (num_negative_samples + num_positive_samples)/num_negative_samples) / (1 - epsilon) # adjust for positive samples (1,1,epsilon)
507+
pc_adjusted = 1 - (deltap - epsilon) / (1 - epsilon) # adjust for positive samples (1,1,epsilon)
506508

507509

508510
t_hats = (np.sum(cdf_estimate > pc_adjusted, axis=1, keepdims=True) == 0) * 1.0 + (1 - (np.sum(cdf_estimate > pc_adjusted, axis=1, keepdims=True) == 0)) * self.thold_grid[np.argmax(cdf_estimate > pc_adjusted, axis=1, keepdims=True)]

0 commit comments

Comments
 (0)