choose_w#
- class choose_w(probs, n, unique=True)[source]#
Choose n items (e.g. people), each with a probability from the distribution probs.
- Parameters:
probs (array) – list of probabilities, should sum to 1
n (int) – number of samples to choose
unique (bool) – whether or not to ensure unique indices
Example:
choices = hpv.choose_w([0.2, 0.5, 0.1, 0.1, 0.1], 2) # choose 2 out of 5 people with nonequal probability.