Skip to main content

pick_weighted_index

Function pick_weighted_index 

Source
fn pick_weighted_index(weights: &[f64]) -> Option<usize>
Expand description

Picks an index into weights with probability proportional to the weight; None if all are non-positive.

Mirrors WeightedCollection::pick_index, which cannot be reused because the callers below select over subsets of a single collection.