Skip to main content

Module weighted_random

Module weighted_random 

Source
Expand description

Weighted random selection helpers. Weighted selection over an arbitrary slice.

Functionsยง

get_random_item
Picks an entry with probability proportional to its weight. A zero total weight returns None without consuming random values.
get_total_weight
Sums weight over items.
get_weighted_item
Returns the entry whose cumulative weight range contains index.