num::categorical_sampling¶
Defined in header <stochastic/concepts.hpp>
template <class S, class G>
concept categorical_sampling =
std::uniform_random_bit_generator<G> && requires(S &sampler, G &rng) {
{ sampler(rng) } -> std::convertible_to<idx>;
};
Sampler drawing an index from a fixed distribution.
\[
P(X = k) = \frac{w_k}{\sum_j w_j}
\]
The weights are non-negative and need not sum to one. Whether a particular set satisfies that is a property of the values, checked by num::stochastic::debug::verify_weights.