random_choice 0.1.0

Chooses samples randomly by their weights/probabilities.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# Rust Random Choice
Chooses samples randomly by their weights/probabilities.

### Advantages

- There is a good diversity for the case that all weights are equally distributed (in contrast to the roulette wheel selection algorithm which tends to select the same sample n times)
- Blazingly fast: O(n) (Roulette wheel selection algorithm: O(n * log n))
- Memory Usage: O(n); in place variant: O(1)
- The sum of the weights don't have to be 1.0, but must not overflow

This algorithm is based on the stochastic universal sampling algorithm.

### Applications
- **Evolutionary algorithms**: Choose the _n_ fittest populations by their fitness **_fi_**
- **Monte Carlo Localization**: Resampling of _n_ particles by their weight **_w_**