Module weighted

Source
Expand description

Weighted (index) sampling

This module is a superset of rand::distr::weighted.

Multiple implementations of weighted index sampling are provided:

  • WeightedIndex (a re-export from rand) supports fast construction and O(log N) sampling over N weights. It also supports updating weights with O(N) time.
  • WeightedAliasIndex supports O(1) sampling, but due to high construction time many samples are required to outperform WeightedIndex.
  • WeightedTreeIndex supports O(log N) sampling and update/insertion/removal of weights with O(log N) time.

Structs§

WeightedAliasIndex
A distribution using weighted sampling to pick a discretely selected item.
WeightedIndex
A distribution using weighted sampling of discrete items.
WeightedTreeIndex
A distribution using weighted sampling to pick a discretely selected item.

Enums§

Error
Invalid weight errors

Traits§

AliasableWeight
Weight bound for WeightedAliasIndex
Weight
Bounds on a weight