Skip to content

num::sample_multinomial

Defined in header <stochastic/multinomial.hpp>

template <std::uniform_random_bit_generator RNG>
array<idx> sample_multinomial(view<const real> weights, idx draws, RNG &random);

Draw multinomial counts by a sequence of conditional binomial draws.

The weights need not be normalized. The returned counts have the same length as weights and sum exactly to draws.