Skip to content

num::sample_categorical

Defined in header <stochastic/categorical.hpp>

template <std::uniform_random_bit_generator RNG>
idx sample_categorical(view<const real> weights, RNG &rng);

Draw an index from nonnegative unnormalized weights in one pass.