Skip to content

random_idx_where: Fix bias

Jim Newsome requested to merge jnewsome/arti:random-idx-where into main

Rewrites random_idx_where to remove a bias that favored choosing elements that occurred after elements that don't satisfy the predicate in the slice. e.g. previously given the call random_idx_where(&mut rng, &[false, false, false, true, true], |b| *b), index 3 had an 80% chance of being chosen.

Edited by Jim Newsome

Merge request reports

Loading