Skip to contents

Warning: this function does no argument checking. Ensure the arguments are as follows.

Usage

draw_multinom(n, prob)

Arguments

n

an integer giving the number of balls to distribute in bins

prob

a vector of probabilities for each bin, which must sum to one

Value

an integer vector of length equal to the length of prob

Note

This function uses the algorithm presented in: Startek, Michał. "An asymptotically optimal, online algorithm for weighted random sampling with replacement." arXiv preprint arXiv:1611.00532 (2016).