struct WeightedIndex<T> { ... }

Weighted discrete distribution.

Returns an index from 0..weights.len() with probability proportional to the weight at that index.

Sampling from this distributions has a complexity of O(log n) where n is the number of weights.

This distribution allocates a vector of cumulative weights on construction, so it needs to be freed when it is no longer needed.

Example

Methods

impl WeightedIndex<T> { ... }

Mixins

impl WeightedIndex<T> { ... }